Reorganize and cleanup the Makefiles.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-06-05 02:16:02 -04:00
parent 530a055733
commit ec3fcbf5dd
2 changed files with 71 additions and 130 deletions
+49 -99
View File
@@ -1,18 +1,14 @@
.PHONY: clean-pyc clean-build .PHONY: clean-pyc clean-build
APT_PROXY ?= `/sbin/ip route|awk '/docker0/ { print $$9 }'`:3142 help: docker-help
DOCKER_VERSION ?= `cat docker/version`
CONSOLE_COLUMNS ?= `echo $$(tput cols)`
CONSOLE_LINES ?= `echo $$(tput lines)`
help:
@echo @echo
@echo "**** Main makefile ****"
@echo "clean-build - Remove build artifacts." @echo "clean-build - Remove build artifacts."
@echo "clean-pyc - Remove Python artifacts." @echo "clean-pyc - Remove Python artifacts."
@echo "clean - Remove Python and build artifacts." @echo "clean - Remove Python and build artifacts."
@echo "generate_setup - Create and updated setup.py" @echo "generate-setup - Create and updated setup.py"
@echo "check_readme - Checks validity of the README.rst file for PyPI publication." @echo "check-readme - Checks validity of the README.rst file for PyPI publication."
@echo "check_missing_migrations - Make sure all models have proper migrations." @echo "check-missing_migrations - Make sure all models have proper migrations."
@echo "test-all - Run all tests." @echo "test-all - Run all tests."
@echo "test MODULE=<python module name> - Run tests for a single app, module or test class." @echo "test MODULE=<python module name> - Run tests for a single app, module or test class."
@@ -23,43 +19,35 @@ help:
@echo "test-with-oracle-all - Run all tests against a Oracle database container." @echo "test-with-oracle-all - Run all tests against a Oracle database container."
@echo "test-oracle MODULE=<python module name> - Run tests for a single app, module or test class against a Oracle database container." @echo "test-oracle MODULE=<python module name> - Run tests for a single app, module or test class against a Oracle database container."
@echo "docs_serve - Run the livehtml documentation generator." @echo "docs-serve - Run the livehtml documentation generator."
@echo "translations_make - Refresh all translation files." @echo "translations-make - Refresh all translation files."
@echo "translations_compile - Compile all translation files." @echo "translations-compile - Compile all translation files."
@echo "translations_push - Upload all translation files to Transifex." @echo "translations-push - Upload all translation files to Transifex."
@echo "translations_pull - Download all translation files from Transifex." @echo "translations-pull - Download all translation files from Transifex."
@echo "requirements_dev - Install development requirements."
@echo "requirements_docs - Install documentation requirements."
@echo "requirements_testing - Install testing requirements."
@echo "sdist - Build the source distribution package." @echo "sdist - Build the source distribution package."
@echo "wheel - Build the wheel distribution package." @echo "wheel - Build the wheel distribution package."
@echo "release - Package (sdist and wheel) and upload a release." @echo "release - Package (sdist and wheel) and upload a release."
@echo "test_release - Package (sdist and wheel) and upload to the PyPI test server." @echo "test-release - Package (sdist and wheel) and upload to the PyPI test server."
@echo "release_test_via_docker_ubuntu - Package (sdist and wheel) and upload to the PyPI test server using an Ubuntu Docker builder." @echo "release-test-via-docker-ubuntu - Package (sdist and wheel) and upload to the PyPI test server using an Ubuntu Docker builder."
@echo "release_test_via_docker_alpine - Package (sdist and wheel) and upload to the PyPI test server using an Alpine Docker builder." @echo "release-via-docker-ubuntu - Package (sdist and wheel) and upload to PyPI using an Ubuntu Docker builder."
@echo "release_via_docker_ubuntu - Package (sdist and wheel) and upload to PyPI using an Ubuntu Docker builder." @echo "test-sdist-via-docker-ubuntu - Make an sdist packange and test it using an Ubuntu Docker container."
@echo "release_via_docker_alpine - Package (sdist and wheel) and upload to PyPI using an Alpine Docker builder." @echo "test-wheel-via-docker-ubuntu - Make a wheel package and test it using an Ubuntu Docker container."
@echo "test_sdist_via_docker_ubuntu - Make an sdist packange and test it using an Ubuntu Docker container."
@echo "test_wheel_via_docker_ubuntu - Make a wheel package and test it using an Ubuntu Docker container."
@echo "runserver - Run the development server." @echo "runserver - Run the development server."
@echo "runserver_plus - Run the Django extension's development server." @echo "runserver_plus - Run the Django extension's development server."
@echo "shell_plus - Run the shell_plus command." @echo "shell_plus - Run the shell_plus command."
@echo "test_with_docker_services_on - Launch and initialize production-like services using Docker (Postgres and Redis)." @echo "test-with-docker-services-on - Launch and initialize production-like services using Docker (Postgres and Redis)."
@echo "test_with_docker_services_off - Stop and delete the Docker production-like services." @echo "test-with-docker-services-off - Stop and delete the Docker production-like services."
@echo "test_with_docker_frontend - Launch a front end instance that uses the production-like services." @echo "test-with-docker-frontend - Launch a front end instance that uses the production-like services."
@echo "test_with_docker_worker - Launch a worker instance that uses the production-like services." @echo "test-with-docker-worker - Launch a worker instance that uses the production-like services."
@echo "docker_mysql_on - Launch and initialize a MySQL Docker container." @echo "docker-mysql-on - Launch and initialize a MySQL Docker container."
@echo "docker_mysql_off - Stop and delete the MySQL Docker container." @echo "docker-mysql-off - Stop and delete the MySQL Docker container."
@echo "docker_postgres_on - Launch and initialize a PostgreSQL Docker container." @echo "docker-postgres-on - Launch and initialize a PostgreSQL Docker container."
@echo "docker_postgres_off - Stop and delete the PostgreSQL Docker container." @echo "docker-postgres-off - Stop and delete the PostgreSQL Docker container."
@echo "safety_check - Run a package safety check."
@echo "safety-check - Run a package safety check."
# Cleaning # Cleaning
@@ -142,7 +130,7 @@ test-with-oracle-all: test-launch-oracle
# Documentation # Documentation
docs_serve: docs-serve:
cd docs;make livehtml cd docs;make livehtml
@@ -161,25 +149,14 @@ translations_pull:
tx pull -f tx pull -f
# Requirements generate-setup:
requirements_dev:
pip install -r requirements/development.txt
requirements_docs:
pip install -r requirements/documentation.txt
requirements_testing:
pip install -r requirements/testing.txt
generate_setup:
@./generate_setup.py @./generate_setup.py
@echo "Complete." @echo "Complete."
# Releases # Releases
test_release: clean wheel test-release: clean wheel
twine upload dist/* -r testpypi twine upload dist/* -r testpypi
@echo "Test with: pip install -i https://testpypi.python.org/pypi mayan-edms" @echo "Test with: pip install -i https://testpypi.python.org/pypi mayan-edms"
@@ -194,7 +171,7 @@ wheel: clean sdist
pip wheel --no-index --no-deps --wheel-dir dist dist/*.tar.gz pip wheel --no-index --no-deps --wheel-dir dist dist/*.tar.gz
ls -l dist ls -l dist
release_test_via_docker_ubuntu: release-test-via-docker-ubuntu:
docker run --rm --name mayan_release -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\ docker run --rm --name mayan_release -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \ echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \
locale-gen en_US.UTF-8 && \ locale-gen en_US.UTF-8 && \
@@ -205,9 +182,9 @@ release_test_via_docker_ubuntu:
apt-get install make python-pip -y && \ apt-get install make python-pip -y && \
pip install -r requirements/build.txt && \ pip install -r requirements/build.txt && \
cp -r /host_home/.pypirc ~/.pypirc && \ cp -r /host_home/.pypirc ~/.pypirc && \
make test_release" make test-release"
release_via_docker_ubuntu: release-via-docker-ubuntu:
docker run --rm --name mayan_release -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\ docker run --rm --name mayan_release -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \ echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \
locale-gen en_US.UTF-8 && \ locale-gen en_US.UTF-8 && \
@@ -220,27 +197,7 @@ release_via_docker_ubuntu:
cp -r /host_home/.pypirc ~/.pypirc && \ cp -r /host_home/.pypirc ~/.pypirc && \
make release" make release"
release_test_via_docker_alpine: test-sdist-via-docker-ubuntu:
docker run --rm --name mayan_release -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source alpine:3.7 /bin/busybox sh -c "\
export LC_ALL=en_US.UTF-8 && \
cp -r /host_source/* . && \
apk update && \
apk add python2 py2-pip make && \
pip install -r requirements/build.txt && \
cp -r /host_home/.pypirc ~/.pypirc && \
make test_release"
release_via_docker_alpine:
docker run --rm --name mayan_release -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source alpine:3.7 /bin/busybox sh -c "\
export LC_ALL=en_US.UTF-8 && \
cp -r /host_source/* . && \
apk update && \
apk add python2 py2-pip make && \
pip install -r requirements/build.txt && \
cp -r /host_home/.pypirc ~/.pypirc && \
make release"
test_sdist_via_docker_ubuntu:
docker run --rm --name mayan_sdist_test -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\ docker run --rm --name mayan_sdist_test -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\
cp -r /host_source/* . && \ cp -r /host_source/* . && \
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \ echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \
@@ -250,10 +207,10 @@ test_sdist_via_docker_ubuntu:
apt-get update && \ apt-get update && \
apt-get install make python-pip libreoffice tesseract-ocr tesseract-ocr-deu poppler-utils -y && \ apt-get install make python-pip libreoffice tesseract-ocr tesseract-ocr-deu poppler-utils -y && \
pip install -r requirements/development.txt && \ pip install -r requirements/development.txt && \
make sdist_test_suit \ make sdist-test-suit \
" "
test_wheel_via_docker_ubuntu: test-wheel-via-docker-ubuntu:
docker run --rm --name mayan_wheel_test -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\ docker run --rm --name mayan_wheel_test -v $(HOME):/host_home:ro -v `pwd`:/host_source -w /source ubuntu:16.04 /bin/bash -c "\
cp -r /host_source/* . && \ cp -r /host_source/* . && \
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \ echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \
@@ -263,10 +220,10 @@ test_wheel_via_docker_ubuntu:
apt-get update && \ apt-get update && \
apt-get install make python-pip libreoffice tesseract-ocr tesseract-ocr-deu poppler-utils -y && \ apt-get install make python-pip libreoffice tesseract-ocr tesseract-ocr-deu poppler-utils -y && \
pip install -r requirements/development.txt && \ pip install -r requirements/development.txt && \
make wheel_test_suit \ make wheel-test-suit \
" "
sdist_test_suit: sdist sdist-test-suit: sdist
rm -f -R _virtualenv rm -f -R _virtualenv
virtualenv _virtualenv virtualenv _virtualenv
sh -c '\ sh -c '\
@@ -277,7 +234,7 @@ sdist_test_suit: sdist
_virtualenv/bin/mayan-edms.py test --mayan-apps \ _virtualenv/bin/mayan-edms.py test --mayan-apps \
' '
wheel_test_suit: wheel wheel-test-suit: wheel
rm -f -R _virtualenv rm -f -R _virtualenv
virtualenv _virtualenv virtualenv _virtualenv
sh -c '\ sh -c '\
@@ -299,7 +256,7 @@ runserver_plus:
shell_plus: shell_plus:
./manage.py shell_plus --settings=mayan.settings.development ./manage.py shell_plus --settings=mayan.settings.development
test_with_docker_services_on: test-with-docker-services-on:
docker run -d --name redis -p 6379:6379 redis docker run -d --name redis -p 6379:6379 redis
docker run -d --name postgres -p 5432:5432 postgres docker run -d --name postgres -p 5432:5432 postgres
while ! nc -z 127.0.0.1 6379; do sleep 1; done while ! nc -z 127.0.0.1 6379; do sleep 1; done
@@ -307,41 +264,41 @@ test_with_docker_services_on:
sleep 4 sleep 4
./manage.py initialsetup --settings=mayan.settings.staging.docker ./manage.py initialsetup --settings=mayan.settings.staging.docker
test_with_docker_services_off: test-with-docker-services-off:
docker stop postgres redis docker stop postgres redis
docker rm postgres redis docker rm postgres redis
test_with_docker_frontend: test-with-docker-frontend:
./manage.py runserver --settings=mayan.settings.staging.docker ./manage.py runserver --settings=mayan.settings.staging.docker
test_with_docker_worker: test-with-docker-worker:
./manage.py celery worker --settings=mayan.settings.staging.docker -B -l INFO -O fair ./manage.py celery worker --settings=mayan.settings.staging.docker -B -l INFO -O fair
docker_mysql_on: docker-mysql-on:
docker run -d --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan_edms mysql docker run -d --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan_edms mysql
while ! nc -z 127.0.0.1 3306; do sleep 1; done while ! nc -z 127.0.0.1 3306; do sleep 1; done
docker_mysql_off: docker-mysql-off:
docker stop mysql docker stop mysql
docker rm mysql docker rm mysql
docker_postgres_on: docker-postgres-on:
docker run -d --name postgres -p 5432:5432 postgres docker run -d --name postgres -p 5432:5432 postgres
while ! nc -z 127.0.0.1 5432; do sleep 1; done while ! nc -z 127.0.0.1 5432; do sleep 1; done
docker_postgres_off: docker-postgres-off:
docker stop postgres docker stop postgres
docker rm postgres docker rm postgres
# Security # Security
safety_check: safety-check:
safety check safety check
# Other # Other
find_gitignores: find-gitignores:
@export FIND_GITIGNORES=`find -name '.gitignore'| wc -l`; \ @export FIND_GITIGNORES=`find -name '.gitignore'| wc -l`; \
if [ $${FIND_GITIGNORES} -gt 1 ] ;then echo "More than one .gitignore found."; fi if [ $${FIND_GITIGNORES} -gt 1 ] ;then echo "More than one .gitignore found."; fi
@@ -359,18 +316,11 @@ build:
make wheel && \ make wheel && \
cp dist/* /host_source/dist/" cp dist/* /host_source/dist/"
check_readme: check-readme:
python setup.py check -r -s python setup.py check -r -s
check_missing_migrations: check-missing-migrations:
./manage.py makemigrations --dry-run --noinput --check ./manage.py makemigrations --dry-run --noinput --check
docker-build: include docker/Makefile
docker build -t mayanedms/mayanedms:$(DOCKER_VERSION) -f docker/Dockerfile .
docker-build-with-proxy:
docker build -t mayanedms/mayanedms:$(DOCKER_VERSION) -f docker/Dockerfile --build-arg APT_PROXY=$(APT_PROXY) .
docker-shell:
docker exec -e TERM=$(TERM) -e "COLUMNS=$(CONSOLE_COLUMNS)" -e "LINES=$(CONSOLE_LINES)" -it $(DOCKER_CONTAINER) /bin/bash
+22 -31
View File
@@ -1,42 +1,33 @@
APT_PROXY ?= `/sbin/ip route|awk '/docker0/ { print $$9 }'`:3142 APT_PROXY ?= `/sbin/ip route|awk '/docker0/ { print $$9 }'`:3142
VERSION ?= `cat version` IMAGE_VERSION ?= `cat docker/version`
CONSOLE_COLUMNS ?= `echo $$(tput cols)`
CONSOLE_LINES ?= `echo $$(tput lines)`
help: docker-help:
@echo @echo
@echo "readme-render - Generate a new README.md from README.md.tmpl." @echo "**** Docker makefile ****"
@echo "release - Push code to trigger and publish a new version build." @echo "docker-build - Build a new image locally."
@echo "build - Build a new image locally." @echo "docker-build-with-proxy - Build a new image locally using an APT proxy."
@echo "build-with-proxy - Build a new image locally using an APT proxy." @echo "docker-test-container - Build and run a test container."
@echo "test-container - Build and run a test container." @echo "docker-test-cleanup - Delete the test container and the test volume."
@echo "test-cleanup - Delete the test container and the test volume." @echo "docker-test-all - Build and executed the test suite in a test container."
@echo "test-all - Build, run a test container, and executed the test suite." @echo "docker-shell - Launch a bash instance inside a running container. Pass the container name via DOCKER_CONTAINER."
readme-render: docker-build:
@export VERSION=$(VERSION); \ docker build -t mayanedms/mayanedms:$(IMAGE_VERSION) -f docker/Dockerfile .
envsubst < README.md.tmpl > README.md
release: docker-build-with-proxy:
git push origin docker build -t mayanedms/mayanedms:$(IMAGE_VERSION) -f docker/Dockerfile --build-arg APT_PROXY=$(APT_PROXY) .
git push --tags origin || true
git push --tags bitbucket || true
git push bitbucket
build: docker-shell:
@export DIRECTORY=`pwd`; \ docker exec -e TERM=$(TERM) -e "COLUMNS=$(CONSOLE_COLUMNS)" -e "LINES=$(CONSOLE_LINES)" -it $(DOCKER_CONTAINER) /bin/bash
export PARENT_DIRECTORY=`dirname "$$DIRECTORY"`; \
docker build -t mayanedms/mayanedms:$(VERSION) -f $$PARENT_DIRECTORY
build-with-proxy: docker-test-container: docker-build-with-proxy docker-test-cleanup
docker build -t mayanedms/mayanedms:$(VERSION) --build-arg APT_PROXY=$(APT_PROXY) . docker run -d --name test-mayan-edms -p 80:8000 -v test-mayan_data:/var/lib/mayan mayanedms/mayanedms:$(DOCKER_VERSION)
test-launch-container: build-with-proxy test-cleanup docker-test-cleanup:
docker run -d --name test-mayan-edms -p 80:80 -v test-mayan_data:/var/lib/mayan mayanedms/mayanedms:$(VERSION)
test-cleanup:
@docker rm -f test-mayan-edms || true @docker rm -f test-mayan-edms || true
@docker volume rm test-mayan_data || true @docker volume rm test-mayan_data || true
test-all: test-launch-container docker-test-all: docker-build-with-proxy
docker exec -ti test-mayan-edms sh -c "apt-get update && apt-get install -y tesseract-ocr-deu" docker run --rm run-tests
docker exec -ti test-mayan-edms sh -c "mayan-edms.py test --mayan-apps"