Skip to content

Commit

Permalink
[change] Migrated to Docker Compose v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jul 17, 2024
1 parent d3bd0ff commit b62561b
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ jobs:
run: make compose-build nfs-build

- name: Test
run: make runtests || (docker-compose logs && exit 1)
run: make runtests || (docker compose logs && exit 1)
env:
SELENIUM_HEADLESS: 1
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ nfs-build:
--file ./images/openwisp_nfs/Dockerfile ./images/

compose-build: base-build
docker-compose build --parallel
docker compose build --parallel

# Test
runtests: develop-runtests
docker-compose stop
docker compose stop

develop-runtests:
docker-compose up -d
docker compose up -d
python3 tests/runtests.py

# Development
develop: compose-build
docker-compose up -d
docker-compose logs -f
docker compose up -d
docker compose logs -f

# Clean
clean:
printf '\e[1;34m%-6s\e[m\n' "Removing docker-openwisp..."
docker-compose stop &> /dev/null
docker-compose down --remove-orphans --volumes --rmi all &> /dev/null
docker-compose rm -svf &> /dev/null
docker compose stop &> /dev/null
docker compose down --remove-orphans --volumes --rmi all &> /dev/null
docker compose rm -svf &> /dev/null
docker rmi --force openwisp/openwisp-base:latest \
openwisp/openwisp-base:intermedia-system \
openwisp/openwisp-base:intermedia-python \
Expand All @@ -76,14 +76,14 @@ USER = registry.gitlab.com/openwisp/docker-openwisp
TAG = latest
start: pull
printf '\e[1;34m%-6s\e[m\n' "Starting Services..."
docker-compose --log-level WARNING up -d
docker compose --log-level WARNING up -d
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..."
docker-compose --log-level ERROR stop
docker-compose --log-level ERROR down --remove-orphans
docker-compose down --remove-orphans &> /dev/null
docker compose --log-level ERROR stop
docker compose --log-level ERROR down --remove-orphans
docker compose down --remove-orphans &> /dev/null

# Publish
USER = registry.gitlab.com/openwisp/docker-openwisp
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ tail -n 50 -f /opt/openwisp/autoinstall.log

### 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.
[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

Expand Down Expand Up @@ -272,7 +272,7 @@ If you want to disable a service, you can simply remove the container for that s

### Workbench setup

1. Install docker & docker-compose.
1. Install Docker & Docker Compose v2.
2. In the root of the repository, run `make develop`, when the containers are ready, you can test them out by going to the domain name of the modules.

**Notes:**
Expand Down
8 changes: 4 additions & 4 deletions deploy/auto-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ setup_docker() {
}

setup_docker_compose() {
start_step "Setting up docker-compose..."
python3 -m pip install docker-compose &>>$LOG_FILE
docker-compose version &>/dev/null
check_status $? "docker-compose installation failed."
start_step "Install docker compose python library..."
python3 -m pip install docker compose &>>$LOG_FILE
docker compose version &>/dev/null
check_status $? "Docker compose installation failed."
}

setup_docker_openwisp() {
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
dashboard:
image: openwisp/openwisp-dashboard:latest
Expand Down
2 changes: 1 addition & 1 deletion docs/ENV.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

The OpenWISP docker images are created with customization in mind. You can simply change the environment variables to change the containers and trailer them to your needs.

- `docker-compose`: You can simply change the values in `.env` file.
- `docker compose`: You can simply change the values in `.env` file.
- `kubernetes`: You need to create `ConfigMap` to change the environment variables. An example is present in `deploy/examples/kubernetes/` directory.

Following are the options that can be changed. The list is divided in following sections:
Expand Down
6 changes: 3 additions & 3 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FAQ: docker-compose
# FAQ: 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)
Expand Down Expand Up @@ -27,8 +27,8 @@ $ git --version
git version 2.20.1
$ docker --version
Docker version 20.10.7, build f0df350
$ docker-compose --version
docker-compose version 1.28.2, build unknown
$ docker compose version
Docker Compose version v2.28.1
$ make --version
GNU Make 4.2.1
$ bash --version
Expand Down
11 changes: 4 additions & 7 deletions docs/QUICK_SETUP.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Quick Setup: docker-compose
# 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)
Expand All @@ -7,12 +7,9 @@

```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
```
sudo apt -y install git

Install [Docker and Docker Compose v2](https://docs.docker.com/compose/install/).

2. Setup repository:

Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
docker @ git+https://github.com/docker/docker-py.git@7785ad913ddf2d86478f08278bb2c488d05a29ff#egg=docker
docker~=7.1.0
openwisp-utils[qa,selenium] @ https://github.com/openwisp/openwisp-utils/tarball/master
13 changes: 7 additions & 6 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def setUpClass(cls):
entrypoint = "python manage.py shell --command='import data; data.setup()'"
cmd = subprocess.Popen(
[
'docker-compose',
'docker',
'compose',
'run',
'--rm',
'--entrypoint',
Expand All @@ -96,7 +97,7 @@ def setUpClass(cls):
logs_file.write(output)
logs_file.write(error)
subprocess.run(
['docker-compose', 'up', '--detach'],
['docker', 'compose', 'up', '--detach'],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
cwd=cls.root_location,
Expand Down Expand Up @@ -146,7 +147,7 @@ def tearDownClass(cls):
cls.base_driver.quit()
if cls.failed_test and cls.config['logs']:
cmd = subprocess.Popen(
['docker-compose', 'logs'],
['docker', 'compose', 'logs'],
universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down Expand Up @@ -437,8 +438,8 @@ def test_freeradius(self):
self.assertIn('Received Access-Accept', result.output.decode('utf-8'))

remove_tainted_container = [
'docker-compose rm -sf freeradius',
'docker-compose up -d freeradius',
'docker compose rm -sf freeradius',
'docker compose up -d freeradius',
]
for command in remove_tainted_container:
subprocess.Popen(
Expand All @@ -453,7 +454,7 @@ def test_containers_down(self):
Ensure freeradius service is working correctly.
"""
cmd = subprocess.Popen(
['docker-compose', 'ps'],
['docker', 'compose', 'ps'],
universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def add_mobile_location_point(self, location_name, driver=None):

def docker_compose_get_container_id(self, container_name):
services_output = subprocess.Popen(
['docker-compose', 'ps', '--quiet', container_name],
['docker', 'compose', 'ps', '--quiet', container_name],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.root_location,
Expand Down

0 comments on commit b62561b

Please sign in to comment.