From 57b079aa3b2e8062ce51e2e32b87886e900db50d Mon Sep 17 00:00:00 2001 From: Ajay Tripathi Date: Tue, 23 Jun 2020 01:18:39 +0530 Subject: [PATCH] [enchancement] Using docker-compose in production --- Makefile | 22 ++++++++++++++++++++++ README.md | 12 ++++++++++-- docs/QUICK_SETUP.md | 31 +++++++++++++++++++++++++++++++ tests/runtests.py | 2 +- 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 docs/QUICK_SETUP.md diff --git a/Makefile b/Makefile index 2f11099a..10261987 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ # the heading "Makefile Options". SHELL := /bin/bash +.SILENT: start stop default: compose-build @@ -56,6 +57,27 @@ clean: openwisp/openwisp-nfs:latest \ `docker images -f "dangling=true" -q` +# Production +start: + printf '\e[1;34m%-6s\e[m\n' "Downloading OpenWISP images..." + # TODO: Log level has bugs and isn't available on common supported version + # but should be used in future + # docker-compose --log-level WARNING pull -q + docker-compose pull &> /dev/null + printf '\e[1;34m%-6s\e[m\n' "Starting Services..." + # docker-compose --log-level WARNING up -d + docker-compose up -d &> /dev/null + printf '\e[1;32m%-6s\e[m\n' "Success: OpenWISP should be available at your dashboard domain in 2 minutes." + +stop: + printf '\e[1;31m%-6s\e[m\n' "Stopping OpenWISP services..." + # TODO: Log level has bugs and isn't available on common supported version + # but should be used in future + # docker-compose --log-level ERROR stop + # docker-compose --log-level ERROR down --remove-orphans + docker-compose stop &> /dev/null + docker-compose down --remove-orphans &> /dev/null + # Publish USER = openwisp TAG = latest diff --git a/README.md b/README.md index 7088af82..a24e1096 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,13 @@ The sample files for deployment on kubernetes are available in the `deployment-e ## Deployment -**Note:** If you are only examining this OpenWISP capabilities, the [workbench setup](#workbench-setup) documentation below might be helpful. +### Compose: + +[Setup on docker-compose](docs/QUICK_SETUP.md) is suitable for single-server setup requirements. It is quicker and requires less prior knowledge about openwisp & networking. + +### Kubernetes: + +Setup on kubernetes is complex and requires prior knowledge about linux systems, kubernetes, docker & openwisp. However, it provides scalability for very large networks. - [Bare Metal](docs/kubernetes/BARE_METAL.md) - [Google Cloud](docs/kubernetes/GOOGLE_CLOUD.md) @@ -121,12 +127,14 @@ You can run tests either with `geckodriver` (firefox) or `chromedriver` (chromiu ### Makefile Options Most commonly used: +- `start`: Start OpenWISP containers on your server. +- `stop`: Stop make containers on your server. - `develop`: Bundles all the commands required to build the images and run containers. - `runtests`: Run testcases to ensure all the services are working. -- `publish` : Build, test and publish images. - `clean`: Aggressively purge all the containers, images, volumes & networks related to `docker-openwisp`. Other options: +- `publish` : Build, test and publish images. - `python-build`: Generate a random django secret and set it in the `.env` file. - `nfs-build`: Build openwisp-nfs server image. - `base-build`: Build openwisp-base image. The base image is used in other OpenWISP images. diff --git a/docs/QUICK_SETUP.md b/docs/QUICK_SETUP.md new file mode 100644 index 00000000..70e6ebe0 --- /dev/null +++ b/docs/QUICK_SETUP.md @@ -0,0 +1,31 @@ +# Quick Setup: docker-compose + +[![Gitter](https://img.shields.io/gitter/room/openwisp/general.svg)](https://gitter.im/openwisp/dockerize-openwisp) +[![Support](https://img.shields.io/badge/support-orange.svg)](http://openwisp.org/support.html) + +1. Install requirements (Debian): + +```bash +sudo apt -y update +sudo apt -y install git docker.io docker-compose make +# Please ensure docker is installed properly and the following +# command show system information. In most machines, you'll need to +# add your user to the `docker` group and re-login to the shell. +docker info +``` + +2. Setup repository: + +```bash +git clone https://github.com/openwisp/docker-openwisp.git +cd docker-openwisp +``` + +3. Configure: + +Please follow the [environment variable documentation](ENV.md) and customize your deployment of OpenWISP. +Remember to change the values for [essential](ENV.md#Essential) and [security](ENV.md#Security) variables. + +4. Deploy: `make start` + +**Note: If you want to shutdown services for maintenance or any other purposes, please use `make stop`.** diff --git a/tests/runtests.py b/tests/runtests.py index 801541dc..a9f5de29 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -27,7 +27,7 @@ def test_wait_for_services(self): max_retries = self.config['services_max_retries'] delay_retries = self.config['services_delay_retries'] admin_login_page = self.config['app_url'] + '/admin/login/' - for i in range(1, max_retries): + for _ in range(1, max_retries): try: # check if we can reach to admin login page # and the page return 200 OK status code