Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert docker-compose to docker compose #2341

Merged
merged 8 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mula_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v4

- name: Build the images
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f base.yml -f .ci/docker-compose.yml build --build-arg PYTHON_VERSION=${{ matrix.version }}
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f base.yml -f .ci/docker-compose.yml build --build-arg PYTHON_VERSION=${{ matrix.version }}
working-directory: ./mula

- name: Run unit tests
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rocky_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
uses: actions/checkout@v4

- name: Build image
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f rocky/base.yml -f rocky/.ci/docker-compose.yml build --build-arg USER_UID="$(id -u)" --build-arg USER_GID="$(id -g)" --build-arg PYTHON_VERSION=${{ matrix.version }} rocky_tests rocky_integration_tests
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f rocky/base.yml -f rocky/.ci/docker-compose.yml build --build-arg USER_UID="$(id -u)" --build-arg USER_GID="$(id -g)" --build-arg PYTHON_VERSION=${{ matrix.version }} rocky_tests rocky_integration_tests

- name: Run tests
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f rocky/base.yml -f rocky/.ci/docker-compose.yml run --rm rocky_tests
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f rocky/base.yml -f rocky/.ci/docker-compose.yml run --rm rocky_tests

- name: Run integration tests
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f rocky/base.yml -f rocky/.ci/docker-compose.yml run --rm rocky_integration_tests
run: DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f rocky/base.yml -f rocky/.ci/docker-compose.yml run --rm rocky_integration_tests
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ reset: clean kat

# Bring up containers
up:
docker-compose up --detach
docker compose up --detach

# Stop containers
stop:
-docker-compose stop
-docker compose stop

# Remove containers but not volumes (no data loss)
down:
-docker-compose down
-docker compose down

# Remove containers and all volumes (data loss!)
clean:
-docker-compose down --timeout 0 --volumes --remove-orphans
-docker compose down --timeout 0 --volumes --remove-orphans
-rm -Rf rocky/node_modules rocky/assets/dist rocky/.parcel-cache rocky/static

# Fetch the latest changes from the Git remote
Expand All @@ -65,7 +65,7 @@ fetch:
# Pull the latest changes from the default upstream
pull:
git pull
docker-compose pull
docker compose pull

# Upgrade to the latest release without losing persistent data. Usage: `make upgrade version=v1.5.0` (version is optional)
VERSION?=$(shell curl -sSf "https://api.github.com/repos/minvws/nl-kat-coordination/tags" | jq -r '[.[].name | select(. | contains("rc") | not)][0]')
Expand All @@ -92,9 +92,9 @@ endif
# Build will prepare all services: migrate them, seed them, etc.
build:
ifeq ($(UNAME),Darwin)
docker-compose build --pull --parallel --build-arg USER_UID="$$(id -u)"
docker compose build --pull --parallel --build-arg USER_UID="$$(id -u)"
else
docker-compose build --pull --parallel --build-arg USER_UID="$$(id -u)" --build-arg USER_GID="$$(id -g)"
docker compose build --pull --parallel --build-arg USER_UID="$$(id -u)" --build-arg USER_GID="$$(id -g)"
endif
make -C rocky build
make -C boefjes build
Expand Down
8 changes: 4 additions & 4 deletions boefjes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ help: ## Show this help.
build: seed

seed: # Seed the katalogus database
-docker-compose run --rm katalogus python -m boefjes.seed
-docker compose run --rm katalogus python -m boefjes.seed

##
##|------------------------------------------------------------------------|
Expand All @@ -42,12 +42,12 @@ migrations: ## Generate a migration using alembic
ifeq ($(m),)
$(HIDE) (echo "Specify a message with m={message} and a rev-id with revid={revid} (e.g. 0001 etc.)"; exit 1)
else
docker-compose run --rm katalogus python -m alembic --config /app/boefjes/boefjes/alembic.ini revision --autogenerate -m "$(m)"
docker compose run --rm katalogus python -m alembic --config /app/boefjes/boefjes/alembic.ini revision --autogenerate -m "$(m)"
endif


sql: ## Generate raw sql for the migrations
docker-compose run --rm katalogus python -m alembic --config /app/boefjes/boefjes/alembic.ini upgrade $(rev1):$(rev2) --sql
docker compose run --rm katalogus python -m alembic --config /app/boefjes/boefjes/alembic.ini upgrade $(rev1):$(rev2) --sql

check:
pre-commit run --all-files --color always
Expand All @@ -57,7 +57,7 @@ check:
## Tests
##|------------------------------------------------------------------------|

ci-docker-compose := docker-compose -f base.yml -f .ci/docker-compose.yml
ci-docker-compose := docker compose -f base.yml -f .ci/docker-compose.yml


test: itest ## Run all tests.
Expand Down
4 changes: 2 additions & 2 deletions bytes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ done: lint test ## Prepare for a commit.
lint: ## Format the code using black.
pre-commit run --all-files --show-diff-on-failure --color always

py-run := docker-compose run --rm bytes python
py-run := docker compose run --rm bytes python


export revid
Expand All @@ -60,7 +60,7 @@ migrate: ## Run alembic migrations
##|------------------------------------------------------------------------|

test: utest itest ## Run all tests.
ci-docker-compose := docker-compose -f base.yml -f .ci/docker-compose.yml
ci-docker-compose := docker compose -f base.yml -f .ci/docker-compose.yml


utest: ## Run the unit tests.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/developer_documentation/mula.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ scheduler. See the environment settings section under Installation and Deploymen

```
# Build and run the scheduler in the background
$ docker-compose up --build -d scheduler
$ docker compose up --build -d scheduler
```

## Testing
Expand Down
12 changes: 6 additions & 6 deletions docs/source/technical_design/containers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Production: Container deployment

OpenKAT can be deployed using containers. We aim to support both simple docker /
docker-compose setups and container orchestration systems like Kubernetes and
docker compose setups and container orchestration systems like Kubernetes and
Nomad.

There is a docker-compose.release-example.yml in the root directory that can be
Expand Down Expand Up @@ -52,7 +52,7 @@ following in the katalogus container:
python3 -m boefjes.seed
```

With docker-compose you would run this as:
With docker compose you would run this as:

```shell
docker compose --env-file .env-prod -f docker-compose.release-example.yml exec katalogus python3 -m boefjes.seed
Expand All @@ -64,7 +64,7 @@ In the rocky container we first need to import the OOI database seed:
python3 manage.py loaddata OOI_database_seed.json
```

With docker-compose you would run this as:
With docker compose you would run this as:

```shell
docker compose --env-file .env-prod -f docker-compose.release-example.yml exec rocky python3 manage.py loaddata OOI_database_seed.json
Expand All @@ -76,7 +76,7 @@ Next we need to create the superuser, this will prompt for the e-mail address an
python3 manage.py createsuperuser
```

With docker-compose you would run this as:
With docker compose you would run this as:

```shell
docker compose --env-file .env-prod -f docker-compose.release-example.yml exec rocky python3 manage.py createsuperuser
Expand All @@ -89,7 +89,7 @@ We also need to create an organisation, this command will create a development o
python3 manage.py setup_dev_account
```

With docker-compose you would run this as:
With docker compose you would run this as:

```shell
docker compose --env-file .env-prod -f docker-compose.release-example.yml exec rocky python3 manage.py setup_dev_account
Expand Down Expand Up @@ -119,7 +119,7 @@ manually using the following command:
python3 manage.py loaddata OOI_database_seed.json
```

With docker-compose you would run this as:
With docker compose you would run this as:

```shell
docker compose --env-file .env-prod -f docker-compose.release-example.yml exec rocky python3 manage.py loaddata OOI_database_seed.json
Expand Down
4 changes: 2 additions & 2 deletions keiko/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ test:
pytest

itest:
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml up -d --build && sleep 1
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml up -d --build && sleep 1
robot -d reports tests/robot
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml down --remove-orphans
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml down --remove-orphans

debian12:
mkdir -p build
Expand Down
14 changes: 7 additions & 7 deletions mula/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export file
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1

ci-docker-compose := docker-compose -f base.yml -f .ci/docker-compose.yml
ci-docker-compose := docker compose -f base.yml -f .ci/docker-compose.yml

##
##+------------------------------------------------------------------------+
Expand All @@ -41,19 +41,19 @@ check: ## Check the code style using black, mypy and pylint.
make pylint

mypy: ## Check code style using mypy.
docker-compose run --rm scheduler \
docker compose run --rm scheduler \
python -m mypy --cache-dir /home/scheduler/.mypy_cache /app/scheduler/scheduler

black: ## Check code style with black.
docker-compose run --rm scheduler \
docker compose run --rm scheduler \
black --check --diff .

pylint: ## Rate the code with pylint.
$(ci-docker-compose) run --rm ci_scheduler_unit \
pylint --rcfile pyproject.toml scheduler

fmt: ## Format the code using black.
docker-compose run --rm scheduler \
docker compose run --rm scheduler \
black .

done: ## Prepare for a commit.
Expand All @@ -73,7 +73,7 @@ cov: ## Generate a test coverage report
##+------------------------------------------------------------------------+

sql: ## Generate raw sql for the migrations.
docker-compose run --rm scheduler \
docker compose run --rm scheduler \
alembic --config /app/scheduler/scheduler/alembic.ini \
upgrade $(rev1):$(rev2) --sql

Expand All @@ -83,14 +83,14 @@ ifeq ($(m),)
else ifeq ($(revid),)
$(HIDE) (echo "ERROR: Specify a message with m={message} and a rev-id with revid={revid} (e.g. 0001 etc.)"; exit 1)
else
docker-compose run --rm scheduler \
docker compose run --rm scheduler \
alembic --config /app/scheduler/scheduler/alembic.ini \
revision --autogenerate \
-m "$(m)" --rev-id "$(revid)"
endif

migrate: ## Run migrations using alembic.
docker-compose run scheduler \
docker compose run scheduler \
alembic --config /app/scheduler/scheduler/alembic.ini \
upgrade head

Expand Down
20 changes: 10 additions & 10 deletions octopoes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ test:
pytest

rtest:
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml kill
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml down --remove-orphans
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml up -d --build octopoes_api octopoes_api_worker
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml kill
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml down --remove-orphans
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml up -d --build octopoes_api octopoes_api_worker
sleep 2
robot -d reports --variablefile tests/robot/variables.py:xtdb tests/robot

itest:
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml kill
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml build $(build_args)
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml down
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml run --rm octopoes_integration
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml kill
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml build $(build_args)
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml down
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml run --rm octopoes_integration

rtest-crux:
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml kill
docker-compose -f docker-compose-base.yml -f .ci/docker-compose-crux.yml down --remove-orphans
docker-compose -f docker-compose-base.yml -f .ci/docker-compose-crux.yml up -d --build octopoes_api octopoes_api_worker
docker compose -f docker-compose-base.yml -f .ci/docker-compose.yml kill
docker compose -f docker-compose-base.yml -f .ci/docker-compose-crux.yml down --remove-orphans
docker compose -f docker-compose-base.yml -f .ci/docker-compose-crux.yml up -d --build octopoes_api octopoes_api_worker
sleep 2
robot -d reports --variablefile tests/robot/variables.py:crux tests/robot || :
4 changes: 2 additions & 2 deletions octopoes/tests/robot/07_rerun_bits.robot
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Rerun bits
Verify Origin Present Hostname|internet|example.com 2

# add the new bit to the bits folder and restart containers
${container_id_worker} Run docker ps -aqf 'name=octopoes_octopoes_api_worker'
${container_id_worker} Run docker ps -aqf 'name=octopoes-octopoes_api_worker'
Log ${container_id_worker}
Run docker cp .ci/mock_bits/url_classification_mock ${container_id_worker}:app/octopoes/bits
Run docker restart ${container_id_worker}

${container_id_api} Run
... docker ps -aq --filter "name=octopoes_octopoes_api" | grep -v $(docker ps -aq --filter "name=octopoes_octopoes_api_worker") | awk '{print $1}'
... docker ps -aq --filter "name=octopoes-octopoes_api" | grep -v $(docker ps -aq --filter "name=octopoes-octopoes_api_worker") | awk '{print $1}'
Log ${container_id_api}
Run docker cp .ci/mock_bits/url_classification_mock ${container_id_api}:app/octopoes/bits
Run docker restart ${container_id_api}
Expand Down
20 changes: 10 additions & 10 deletions rocky/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build: build-rocky build-rocky-frontend

build-rocky:
# Set DATABASE_MIGRATION=false to prevent entrypoint from running migration
docker-compose run --rm -e DATABASE_MIGRATION=false rocky make build-rocky-native
docker compose run --rm -e DATABASE_MIGRATION=false rocky make build-rocky-native

build-rocky-native:
while ! nc -vz $$ROCKY_DB_HOST $$ROCKY_DB_PORT; do sleep 0.1; done
Expand All @@ -26,7 +26,7 @@ build-rocky-frontend:
docker run --rm -v $$PWD:/app/rocky node:20-bookworm sh -c "cd /app/rocky && yarn --ignore-engine && yarn build && chown -R $$(id -u) .parcel-cache node_modules assets/dist"

almost-flush:
docker-compose run --rm rocky python manage.py almost_flush
docker compose run --rm rocky python manage.py almost_flush

run:
python3 manage.py runserver
Expand All @@ -35,16 +35,16 @@ test:
python3 manage.py test

utest: ## Run the integration tests.
docker-compose -f base.yml -f .ci/docker-compose.yml kill
docker-compose -f base.yml -f .ci/docker-compose.yml down --remove-orphans
docker-compose -f base.yml -f .ci/docker-compose.yml build
docker-compose -f base.yml -f .ci/docker-compose.yml run --rm rocky_tests
docker compose -f base.yml -f .ci/docker-compose.yml kill
docker compose -f base.yml -f .ci/docker-compose.yml down --remove-orphans
docker compose -f base.yml -f .ci/docker-compose.yml build
docker compose -f base.yml -f .ci/docker-compose.yml run --rm rocky_tests

itest: ## Run the integration tests.
docker-compose -f base.yml -f .ci/docker-compose.yml kill
docker-compose -f base.yml -f .ci/docker-compose.yml down --remove-orphans
docker-compose -f base.yml -f .ci/docker-compose.yml build
docker-compose -f base.yml -f .ci/docker-compose.yml run --rm rocky_integration_tests
docker compose -f base.yml -f .ci/docker-compose.yml kill
docker compose -f base.yml -f .ci/docker-compose.yml down --remove-orphans
docker compose -f base.yml -f .ci/docker-compose.yml build
docker compose -f base.yml -f .ci/docker-compose.yml run --rm rocky_integration_tests

export_migrations:
python manage.py export_migrations contenttypes 0001
Expand Down