Skip to content
This repository was archived by the owner on Mar 16, 2023. It is now read-only.

Commit b311756

Browse files
authored
⬆️Maintenance: docker compose v2 (#46)
1 parent fba2957 commit b311756

File tree

15 files changed

+91
-51
lines changed

15 files changed

+91
-51
lines changed

.github/workflows/gateway.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ env:
3030
# DOCKER_REGISTRY: must be one of docker.io, ghcr.io, registry.gitlab.com, <registry-name>.azurecr.io, gcr.io, <location>-docker.pkg.dev, <aws-account-number>.dkr.ecr.<region>.amazonaws.com, public.ecr.aws, <region>.ocir.io, quay.io, or custom (not tested)
3131
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
3232

33+
concurrency:
34+
# ensure only one CI runs at a time
35+
group: ${{ github.workflow }}-${{ github.ref }}
36+
cancel-in-progress: true
37+
3338
jobs:
3439
unit-test:
3540
timeout-minutes: 10
@@ -158,7 +163,7 @@ jobs:
158163
matrix:
159164
python: [3.9]
160165
os: [ubuntu-20.04]
161-
docker_buildx: [v0.7.0]
166+
docker_buildx: [v0.10.2]
162167
fail-fast: false
163168
runs-on: ${{ matrix.os }}
164169

Makefile

+38-9
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,53 @@ $(OSPARC_GATEWAY_CONFIG_FILE_HOST): services/osparc-gateway-server/config/defaul
130130
@echo "WARNING ##### $@ does not exist, cloning $< as $@ ############"; cp $< $@)
131131

132132

133+
# REFERENCE: https://github.com/docker/compose/issues/9306
134+
# composeV2 defines specifications for docker compose to run
135+
# they are not 100% compatible with what docker stack deploy command expects
136+
# some parts have to be modified
137+
define generate_docker_compose_specs
138+
docker --log-level=ERROR compose --env-file .env \
139+
$(foreach file,$1,--file=$(file)) \
140+
config \
141+
| sed '/published:/s/"//g' \
142+
| sed '/size:/s/"//g' \
143+
| sed '1 { /name:.*/d ; }' \
144+
| sed '1 i\version: \"3.9\"' \
145+
| sed --regexp-extended "s/cpus: ([0-9\\.]+)/cpus: '\\1'/" \
146+
> $@
147+
endef
148+
149+
133150
.stack-$(SWARM_STACK_NAME)-development.yml: .env $(docker-compose-configs)
134151
# Creating config for stack with 'local/{service}:development' to $@
135152
@export DOCKER_REGISTRY=local \
136153
export DOCKER_IMAGE_TAG=development; \
137-
docker-compose --env-file .env --file services/docker-compose.yml --file services/docker-compose.local.yml --file services/docker-compose.devel.yml --log-level=ERROR config > $@
154+
$(call generate_docker_compose_specs,\
155+
services/docker-compose.yml \
156+
services/docker-compose.local.yml \
157+
services/docker-compose.devel.yml\
158+
)
138159

139160
.stack-$(SWARM_STACK_NAME)-production.yml: .env $(docker-compose-configs)
140161
# Creating config for stack with 'local/{service}:production' to $@
141162
@export DOCKER_REGISTRY=local; \
142163
export DOCKER_IMAGE_TAG=production; \
143-
docker-compose --env-file .env --file services/docker-compose.yml --file services/docker-compose.local.yml --log-level=ERROR config > $@
164+
$(call generate_docker_compose_specs,\
165+
services/docker-compose.yml \
166+
services/docker-compose.local.yml\
167+
)
144168

145169
.stack-$(SWARM_STACK_NAME)-version.yml: .env $(docker-compose-configs)
146170
# Creating config for stack with '$(DOCKER_REGISTRY)/{service}:${DOCKER_IMAGE_TAG}' to $@
147-
@docker-compose --env-file .env --file services/docker-compose.yml --file services/docker-compose.local.yml --log-level=ERROR config > $@
171+
@$(call generate_docker_compose_specs,\
172+
services/docker-compose.yml \
173+
services/docker-compose.local.yml\
174+
)
148175

149176
.stack-$(SWARM_STACK_NAME)-ops.yml: .env $(docker-compose-configs)
150177
# Creating config for ops stack to $@
151-
@docker-compose --env-file .env --file services/docker-compose-ops.yml --log-level=ERROR config > $@
178+
@$(call generate_docker_compose_specs,\
179+
services/docker-compose-ops.yml)
152180

153181

154182
.PHONY: up-devel up-prod up-version up-latest
@@ -194,7 +222,7 @@ ifeq ($(target),)
194222
@$(MAKE) .deploy-ops
195223
else
196224
# deploys ONLY $(target) service
197-
@docker-compose --file $< up --detach $(target)
225+
@docker compose --file $< up --detach $(target)
198226
endif
199227
@$(_show_endpoints)
200228

@@ -214,6 +242,7 @@ down: ## Stops and removes stack
214242
-@docker stack rm $(SWARM_STACK_NAME)-ops
215243
# Removing generated docker compose configurations, i.e. .stack-*
216244
-@rm $(wildcard .stack-*)
245+
-@rm $(wildcard $(OSPARC_GATEWAY_CONFIG_FILE_HOST))
217246

218247
leave: ## Forces to stop all services, networks, etc by the node leaving the swarm
219248
-docker swarm leave -f
@@ -255,7 +284,7 @@ tag-latest: ## Tags last locally built production images as '${DOCKER_REGISTRY}/
255284

256285
pull-version: .env ## pulls images from DOCKER_REGISTRY tagged as DOCKER_IMAGE_TAG
257286
# Pulling images '${DOCKER_REGISTRY}/{service}:${DOCKER_IMAGE_TAG}'
258-
@docker-compose --file services/docker-compose-deploy.yml pull
287+
@docker compose --file services/docker-compose-deploy.yml pull
259288

260289

261290
.PHONY: push-version push-latest
@@ -268,7 +297,7 @@ push-latest: tag-latest
268297
push-version: tag-version
269298
# pushing '${DOCKER_REGISTRY}/{service}:${DOCKER_IMAGE_TAG}'
270299
@export BUILD_TARGET=undefined; \
271-
docker-compose --file services/docker-compose-build.yml --file services/docker-compose-deploy.yml push
300+
docker compose --file services/docker-compose-build.yml --file services/docker-compose-deploy.yml push
272301

273302
## ENVIRONMENT -------------------------------
274303

@@ -277,7 +306,7 @@ push-version: tag-version
277306
.venv:
278307
python3 -m venv $@
279308
$@/bin/pip3 --quiet install --upgrade \
280-
pip~=21.3 \
309+
pip~=23.0 \
281310
wheel \
282311
setuptools
283312

@@ -317,7 +346,7 @@ info: ## displays setup information
317346
@echo ' node : $(shell node --version 2> /dev/null || echo ERROR nodejs missing)'
318347
@echo ' docker : $(shell docker --version)'
319348
@echo ' docker buildx : $(shell docker buildx version)'
320-
@echo ' docker-compose: $(shell docker-compose --version)'
349+
@echo ' docker-compose: $(shell docker compose --version)'
321350

322351

323352
define show-meta

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The oSparc connects to that gateway and starts a Dask cluster made of a *itisfou
3939
git clone https://github.com/ITISFoundation/osparc-dask-gateway.git
4040
cd osparc-dask-gateway
4141
make up
42-
# this should output the address and passwor on how to connect with the gateway
42+
# this should output the address and password on how to connect with the gateway
4343
```
4444

4545
## Testing the gateway

ci/helpers/show_system_versions.bash

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if command -v docker; then
3232
docker buildx version
3333
fi
3434

35-
echo "------------------------------ docker-compose -----------------------------------"
36-
if command -v docker-compose; then
37-
docker-compose version
35+
echo "------------------------------ docker compose -----------------------------------"
36+
if command -v docker; then
37+
docker compose version
3838
fi

services/docker-compose.local.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ services:
44
environment:
55
- SC_BOOT_MODE=${SC_BOOT_MODE:-default}
66
ports:
7-
- "8000:8000"
87
- "3100:3000" # ptvsd port

services/docker-compose.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3.6' # Don't touch
1+
version: '3.9'
22
services:
33
osparc-gateway-server:
44
image: ${DOCKER_REGISTRY:-itisfoundation}/osparc-gateway-server:${DOCKER_IMAGE_TAG:-latest}
@@ -24,7 +24,8 @@ services:
2424
constraints:
2525
- node.role == manager
2626
networks:
27-
dask_net: null
27+
dask_net:
28+
name: ${SWARM_STACK_NAME:?swarm_stack_name_required}_dask_net
2829

2930
volumes:
3031
sidecar_data: null

services/osparc-gateway-server/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ RUN --mount=type=cache,id=build-cache,target=/var/cache/apt,mode=0755,sharing=l
7777
RUN python -m venv "${VIRTUAL_ENV}"
7878
RUN --mount=type=cache,mode=0777,target=/root/.cache/pip \
7979
pip install --upgrade \
80-
pip~=21.3.1 \
80+
pip~=23.0.1 \
8181
wheel \
8282
setuptools
8383

services/osparc-gateway-server/requirements/_base.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ bokeh==3.0.3
2121
# via -r requirements/_base.in
2222
cffi==1.15.1
2323
# via cryptography
24-
charset-normalizer==3.0.1
24+
charset-normalizer==3.1.0
2525
# via aiohttp
2626
colorlog==6.7.0
2727
# via dask-gateway-server
2828
contourpy==1.0.7
2929
# via bokeh
30-
cryptography==39.0.1
30+
cryptography==39.0.2
3131
# via
3232
# -c requirements/../../../requirements/constraints.txt
3333
# dask-gateway-server

services/osparc-gateway-server/requirements/_test.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# testing
1414
pytest
15-
pytest-aiohttp # incompatible with pytest-asyncio. See https://github.com/pytest-dev/pytest-asyncio/issues/76
15+
pytest-asyncio
1616
pytest-cov
1717
pytest-mock
1818
pytest-xdist

services/osparc-gateway-server/requirements/_test.txt

+8-12
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ aiohttp==3.8.4
99
# -c requirements/../../../requirements/constraints.txt
1010
# -c requirements/_base.txt
1111
# dask-gateway
12-
# pytest-aiohttp
1312
aiosignal==1.3.1
1413
# via
1514
# -c requirements/_base.txt
1615
# aiohttp
17-
astroid==2.14.2
16+
astroid==2.15.0
1817
# via pylint
1918
async-timeout==4.0.2
2019
# via
@@ -27,7 +26,7 @@ attrs==22.2.0
2726
# pytest
2827
certifi==2022.12.7
2928
# via requests
30-
charset-normalizer==3.0.1
29+
charset-normalizer==3.1.0
3130
# via
3231
# -c requirements/_base.txt
3332
# aiohttp
@@ -75,14 +74,14 @@ exceptiongroup==1.1.0
7574
# via pytest
7675
execnet==1.9.0
7776
# via pytest-xdist
78-
faker==17.5.0
77+
faker==17.6.0
7978
# via -r requirements/_test.in
8079
frozenlist==1.3.3
8180
# via
8281
# -c requirements/_base.txt
8382
# aiohttp
8483
# aiosignal
85-
fsspec==2023.1.0
84+
fsspec==2023.3.0
8685
# via dask
8786
heapdict==1.0.1
8887
# via zict
@@ -130,30 +129,27 @@ packaging==23.0
130129
# pytest
131130
partd==1.3.0
132131
# via dask
133-
platformdirs==3.0.0
132+
platformdirs==3.1.0
134133
# via pylint
135134
pluggy==1.0.0
136135
# via pytest
137136
pprintpp==0.4.0
138137
# via pytest-icdiff
139138
psutil==5.9.4
140139
# via distributed
141-
pylint==2.16.2
140+
pylint==2.16.4
142141
# via -r requirements/_test.in
143-
pytest==7.2.1
142+
pytest==7.2.2
144143
# via
145144
# -r requirements/_test.in
146-
# pytest-aiohttp
147145
# pytest-asyncio
148146
# pytest-cov
149147
# pytest-icdiff
150148
# pytest-mock
151149
# pytest-watch
152150
# pytest-xdist
153-
pytest-aiohttp==1.0.4
154-
# via -r requirements/_test.in
155151
pytest-asyncio==0.20.3
156-
# via pytest-aiohttp
152+
# via -r requirements/_test.in
157153
pytest-cov==4.0.0
158154
# via -r requirements/_test.in
159155
pytest-icdiff==0.6

services/osparc-gateway-server/requirements/_tools.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pathspec==0.11.0
4141
# via black
4242
pip-tools==6.12.3
4343
# via -r requirements/../../../requirements/devenv.txt
44-
platformdirs==3.0.0
44+
platformdirs==3.1.0
4545
# via
4646
# -c requirements/_test.txt
4747
# black

tests/Makefile

+17-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,25 @@ install-dev install-prod install-ci: _check_venv_active ## install requirements
1919

2020

2121
.PHONY: tests
22-
tests: _check_venv_active ## runs all tests [DEV]
23-
# running unit tests
22+
tests: _check_venv_active ## runs all tests [CI]
23+
# running system tests
2424
pytest \
25-
-vv \
25+
--asyncio-mode=auto \
2626
--color=yes \
2727
--durations=10 \
28+
-vv \
29+
$(CURDIR)
30+
31+
.PHONY: test-dev
32+
tests-dev: _check_venv_active ## runs all tests [DEV]
33+
# running system tests
34+
@pytest \
2835
--asyncio-mode=auto \
36+
--color=yes \
37+
--durations=10 \
38+
--exitfirst \
39+
--failed-first \
40+
--keep-docker-up \
41+
--pdb \
42+
-vv \
2943
$(CURDIR)

tests/requirements/_test.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# testing
55
pytest
6-
pytest-aiohttp
6+
pytest-asyncio
77
pytest-cov
88
pytest-icdiff
99
pytest-instafail

0 commit comments

Comments
 (0)