From 782c4a365e36d338caa5c00cb8ac694a27496d21 Mon Sep 17 00:00:00 2001 From: Ajay Tripathi Date: Wed, 29 May 2019 20:37:41 +0530 Subject: [PATCH] [improvement] Add options in Makefile + Documentation --- .travis.yml | 4 +--- Makefile | 56 +++++++++++++++++++++++++++++++++++++++++++++-------- README.md | 16 +++++++++++++++ 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index bafa2979..6ae5d5f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,4 @@ jobs: include: - stage: tests script: - - echo "127.0.0.1 dashboard.openwisp.org controller.openwisp.org radius.openwisp.org topology.openwisp.org" | sudo tee -a /etc/hosts - - make compose-build - - make runtests + - make travis-runtests diff --git a/Makefile b/Makefile index 3370c9d1..85adec6f 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ -# Makefile to create all the docker-images +# Find documentation in README.md under +# heading "Makefile Options". SHELL := /bin/bash +default: compose-build + # Build -compose-build: build-base - docker-compose build - python build.py default-secret-key +python-build: build.py + python build.py change-secret-key -build-base: python-build-script +build-base: docker build --tag openwisp/openwisp-base:intermedia-system \ --file ./build/openwisp_base/Dockerfile \ --target SYSTEM ./build/ @@ -17,11 +19,49 @@ build-base: python-build-script docker build --tag openwisp/openwisp-base:latest \ --file ./build/openwisp_base/Dockerfile ./build/ -python-build-script: build.py - python build.py change-secret-key +compose-build: python-build build-base + docker-compose build --parallel + python build.py default-secret-key + +publish-build: build-base + docker-compose build --parallel # Test -runtests: +runtests: develop-runtests + docker-compose stop + +develop-runtests: publish-build + docker-compose up -d + source ./tests/tests.sh && init_dashoard_tests + +travis-runtests: publish-build docker-compose up -d + echo "127.0.0.1 dashboard.openwisp.org controller.openwisp.org" \ + "radius.openwisp.org topology.openwisp.org" | sudo tee -a /etc/hosts source ./tests/tests.sh && init_dashoard_tests logs + +# Development +develop: publish-build + docker-compose up -d + docker-compose logs -f + +# Clean +clean: docker-compose stop + docker-compose down --remove-orphans --volumes --rmi all + docker-compose rm -svf + docker rmi --force openwisp/openwisp-base:latest \ + openwisp/openwisp-base:intermedia-system \ + openwisp/openwisp-base:intermedia-python \ + `docker images -f "dangling=true" -q` || true + +# Publish +publish: publish-build travis-runtests + docker push openwisp/openwisp-base:latest + docker push openwisp/openwisp-nginx:latest + docker push openwisp/openwisp-dashboard:latest + docker push openwisp/openwisp-radius:latest + docker push openwisp/openwisp-controller:latest + docker push openwisp/openwisp-topology:latest + docker push openwisp/openwisp-websocket:latest + docker push openwisp/openwisp-postfix:latest diff --git a/README.md b/README.md index ddbd66a4..dfdb052a 100644 --- a/README.md +++ b/README.md @@ -142,3 +142,19 @@ To disable an openwisp service container and plug your own service like database - Change the [email configuration variables](docs/ENV.md) to point to your instances. - openwisp-nginx: - Configurations in `build/openwisp_nginx/` are helpful to replicate in your own instance. + +# Makefile Options + +**Right now, this is only tentative guide. Errata may exist. Please report errors on the [gitter channel](https://gitter.im/openwisp/general).** + +The Makefile has following options, that are useful for developers & users. Default action is `compose-build`. + +`build-base`: Build openwisp-base image. It is the base image used in other images. It takes the most time to build. +`compose-build`: Build the openwisp images. This option must be used in most usecases, example when a user is building custom images. +`publish-build`: Similar to `compose-build` except the produced are used for publishing the Official images. +`runtests`: Run tests on local machine. +`develop-runtests`: Similar to `runtests` except doesn't stop containers after running the tests. +`travis-runtests`: Similar to `runtests` except used in travis builds because it doesn't clean up after running the tests and prints all the container's logs when an error occurs in the tests. +`develop`: Useful for development. Bundles all the commands required to build and run images during development. +`clean`: Purge everything produced during building the images. +`publish`: Build, test and publish the latest Official images.