Skip to content

Commit

Permalink
Merge pull request openwisp#119 from atb00ker/run-in-docker-compose
Browse files Browse the repository at this point in the history
[enchancement] Using docker-compose in production
  • Loading branch information
atb00ker authored Jun 26, 2020
2 parents 6734a2d + 57b079a commit 94c0884
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# the heading "Makefile Options".

SHELL := /bin/bash
.SILENT: start stop

default: compose-build

Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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` <USER=docker-username> <TAG=image-tag>: Build, test and publish images.
- `clean`: Aggressively purge all the containers, images, volumes & networks related to `docker-openwisp`.

Other options:
- `publish` <USER=docker-username> <TAG=image-tag>: 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.
Expand Down
31 changes: 31 additions & 0 deletions docs/QUICK_SETUP.md
Original file line number Diff line number Diff line change
@@ -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`.**
2 changes: 1 addition & 1 deletion tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 94c0884

Please sign in to comment.