Skip to content

Commit

Permalink
[improvement] Add options in Makefile + Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
atb00ker committed Jul 12, 2019
1 parent f1d1ca6 commit 782c4a3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 11 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
56 changes: 48 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 782c4a3

Please sign in to comment.