Skip to content

Commit

Permalink
refactor docker compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
rafsaf committed Oct 12, 2023
1 parent 2efc61b commit 0866a43
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Build and push backuper image
uses: docker/build-push-action@v5
with:
file: Dockerfile
file: docker/Dockerfile
context: .
target: build
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Build and push backuper image
uses: docker/build-push-action@v5
with:
file: Dockerfile
file: docker/Dockerfile
context: .
target: build
push: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: touch .env

- name: Download and start db containers
run: docker compose up -d postgres_16 postgres_15 postgres_14 postgres_13 postgres_12 postgres_11 mysql_57 mysql_80 mysql_81 mariadb_1101 mariadb_1011 mariadb_1006 mariadb_1005 mariadb_1004
run: make docker_dbs_setup

- name: Build image and run tests in container
run: docker compose run --rm --build backuper_tests_${{ matrix.arch }}
run: make tests_${{ matrix.arch }}
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# to run tests with arm64 see https://docs.docker.com/build/building/multi-platform/
docker_dbs_setup:
docker compose -f docker/docker-compose.dbs.yml up -d

tests_amd64:
docker compose -f docker/docker-compose.tests.yml run --rm backuper_tests_amd64

tests_arm64:
docker compose -f docker/docker-compose.tests.yml run --rm backuper_tests_arm64

acceptance_tests_amd64:
docker compose -f docker/docker-compose.tests.yml run --rm backuper_acceptance_test_amd64

acceptance_tests_arm64:
docker compose -f docker/docker-compose.tests.yml run --rm backuper_acceptance_test_arm64
File renamed without changes.
24 changes: 24 additions & 0 deletions docker/docker-compose.acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
backuper_acceptance_test_amd64:
restart: "no"
network_mode: "host"
platform: linux/amd64
build:
context: ./../
dockerfile: docker/Dockerfile
target: build
command: python -m backuper.main --single
env_file:
- .env

backuper_acceptance_test_arm64:
restart: "no"
network_mode: "host"
platform: linux/arm64
build:
context: ./../
dockerfile: docker/Dockerfile
target: build
command: python -m backuper.main --single
env_file:
- .env
200 changes: 44 additions & 156 deletions docker-compose.yml → docker/docker-compose.dbs.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
# also used in GH workflows
# set up dbs
# docker compose up -d postgres_16 postgres_15 postgres_14 postgres_13 postgres_12 postgres_11 mysql_57 mysql_80 mysql_81 mariadb_1101 mariadb_1011 mariadb_1006 mariadb_1005 mariadb_1004
# run tests amd64
# docker compose run --rm --build backuper_tests_amd64
# run tests arm64 see https://docs.docker.com/build/building/multi-platform/
# docker compose run --rm --build backuper_tests_arm64
# run acceptance test with AWS then GCP then Azure in .env
# docker compose run --rm --build backuper_acceptance_test_amd64
# docker compose run --rm --build backuper_acceptance_test_arm64

services:
postgres_16:
restart: "no"
restart: "no"
networks:
- backuper
image: postgres:16.0
environment:
- POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -21,7 +12,9 @@ services:
- 10016:5432

postgres_15:
restart: "no"
restart: "no"
networks:
- backuper
image: postgres:15.4
environment:
- POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -31,7 +24,9 @@ services:
- 10015:5432

postgres_14:
restart: "no"
restart: "no"
networks:
- backuper
image: postgres:14.9
environment:
- POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -41,7 +36,9 @@ services:
- 10014:5432

postgres_13:
restart: "no"
restart: "no"
networks:
- backuper
image: postgres:13.12
environment:
- POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -51,7 +48,9 @@ services:
- 10013:5432

postgres_12:
restart: "no"
restart: "no"
networks:
- backuper
image: postgres:12.16
environment:
- POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -61,7 +60,9 @@ services:
- 10012:5432

postgres_11:
restart: "no"
restart: "no"
networks:
- backuper
image: postgres:11.21-bookworm
environment:
- POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -71,7 +72,9 @@ services:
- 10011:5432

mysql_57:
restart: "no"
restart: "no"
networks:
- backuper
image: mysql:5.7.42
environment:
- MYSQL_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -82,7 +85,9 @@ services:
- 10057:3306

mysql_80:
restart: "no"
restart: "no"
networks:
- backuper
image: mysql:8.0.34
environment:
- MYSQL_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -93,7 +98,9 @@ services:
- 10080:3306

mysql_81:
restart: "no"
restart: "no"
networks:
- backuper
image: mysql:8.1.0
environment:
- MYSQL_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -104,7 +111,9 @@ services:
- 10081:3306

mariadb_1101:
restart: "no"
restart: "no"
networks:
- backuper
image: mariadb:11.1.2
environment:
- MARIADB_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -115,7 +124,9 @@ services:
- 11101:3306

mariadb_1011:
restart: "no"
restart: "no"
networks:
- backuper
image: mariadb:10.11.2
environment:
- MARIADB_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -126,7 +137,9 @@ services:
- 11011:3306

mariadb_1006:
restart: "no"
restart: "no"
networks:
- backuper
image: mariadb:10.6.12
environment:
- MARIADB_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -137,7 +150,9 @@ services:
- 11006:3306

mariadb_1005:
restart: "no"
restart: "no"
networks:
- backuper
image: mariadb:10.5.19
environment:
- MARIADB_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -148,7 +163,9 @@ services:
- 11005:3306

mariadb_1004:
restart: "no"
restart: "no"
networks:
- backuper
image: mariadb:10.4.28
environment:
- MARIADB_ROOT_PASSWORD=root-password-_-12!@#%^&*()/;><.,]}{[
Expand All @@ -158,134 +175,5 @@ services:
ports:
- 11004:3306

backuper_tests_amd64:
restart: "no"
platform: linux/amd64
depends_on:
- postgres_16
- postgres_15
- postgres_14
- postgres_13
- postgres_12
- postgres_11
- mysql_57
- mysql_80
- mysql_81
- mariadb_1101
- mariadb_1011
- mariadb_1006
- mariadb_1005
- mariadb_1004
build:
context: ./
dockerfile: Dockerfile
target: tests
environment:
- DOCKER_TESTS=true
- ZIP_ARCHIVE_PASSWORD=password

backuper_tests_arm64:
restart: "no"
platform: linux/arm64
depends_on:
- postgres_16
- postgres_15
- postgres_14
- postgres_13
- postgres_12
- postgres_11
- mysql_57
- mysql_80
- mysql_81
- mariadb_1101
- mariadb_1011
- mariadb_1006
- mariadb_1005
- mariadb_1004
build:
context: ./
dockerfile: Dockerfile
target: tests
environment:
- DOCKER_TESTS=true
- ZIP_ARCHIVE_PASSWORD=password

backuper_acceptance_test:
restart: "no"
network_mode: "host"
depends_on:
- postgres_16
- postgres_15
- postgres_14
- postgres_13
- postgres_12
- postgres_11
- mysql_57
- mysql_80
- mysql_81
- mariadb_1101
- mariadb_1011
- mariadb_1006
- mariadb_1005
- mariadb_1004
build:
context: ./
dockerfile: Dockerfile
target: build
command: python -m backuper.main --single
env_file:
- .env

backuper_acceptance_test_amd64:
restart: "no"
network_mode: "host"
platform: linux/amd64
depends_on:
- postgres_16
- postgres_15
- postgres_14
- postgres_13
- postgres_12
- postgres_11
- mysql_57
- mysql_80
- mysql_81
- mariadb_1101
- mariadb_1011
- mariadb_1006
- mariadb_1005
- mariadb_1004
build:
context: ./
dockerfile: Dockerfile
target: build
command: python -m backuper.main --single
env_file:
- .env

backuper_acceptance_test_arm64:
restart: "no"
network_mode: "host"
platform: linux/arm64
depends_on:
- postgres_16
- postgres_15
- postgres_14
- postgres_13
- postgres_12
- postgres_11
- mysql_57
- mysql_80
- mysql_81
- mariadb_1101
- mariadb_1011
- mariadb_1006
- mariadb_1005
- mariadb_1004
build:
context: ./
dockerfile: Dockerfile
target: build
command: python -m backuper.main --single
env_file:
- .env
networks:
backuper:
Loading

0 comments on commit 0866a43

Please sign in to comment.