diff --git a/.github/workflows/dev_build.yml b/.github/workflows/dev_build.yml index 76e7011..47614aa 100644 --- a/.github/workflows/dev_build.yml +++ b/.github/workflows/dev_build.yml @@ -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 diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index 77d3050..5f4006b 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 416a432..bc9f19d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..95d1218 --- /dev/null +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/Dockerfile b/docker/Dockerfile similarity index 100% rename from Dockerfile rename to docker/Dockerfile diff --git a/docker/docker-compose.acceptance.yml b/docker/docker-compose.acceptance.yml new file mode 100644 index 0000000..403823d --- /dev/null +++ b/docker/docker-compose.acceptance.yml @@ -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 \ No newline at end of file diff --git a/docker-compose.yml b/docker/docker-compose.dbs.yml similarity index 53% rename from docker-compose.yml rename to docker/docker-compose.dbs.yml index c27c2de..dc1e8c8 100644 --- a/docker-compose.yml +++ b/docker/docker-compose.dbs.yml @@ -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!@#%^&*()/;><.,]}{[ @@ -21,7 +12,9 @@ services: - 10016:5432 postgres_15: - restart: "no" + restart: "no" + networks: + - backuper image: postgres:15.4 environment: - POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[ @@ -31,7 +24,9 @@ services: - 10015:5432 postgres_14: - restart: "no" + restart: "no" + networks: + - backuper image: postgres:14.9 environment: - POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[ @@ -41,7 +36,9 @@ services: - 10014:5432 postgres_13: - restart: "no" + restart: "no" + networks: + - backuper image: postgres:13.12 environment: - POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[ @@ -51,7 +48,9 @@ services: - 10013:5432 postgres_12: - restart: "no" + restart: "no" + networks: + - backuper image: postgres:12.16 environment: - POSTGRES_PASSWORD=password-_-12!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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!@#%^&*()/;><.,]}{[ @@ -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 \ No newline at end of file +networks: + backuper: \ No newline at end of file diff --git a/docker/docker-compose.tests.yml b/docker/docker-compose.tests.yml new file mode 100644 index 0000000..83840eb --- /dev/null +++ b/docker/docker-compose.tests.yml @@ -0,0 +1,40 @@ +# 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: + backuper_tests_amd64: + restart: "no" + networks: + - backuper + platform: linux/amd64 + build: + context: ./../ + dockerfile: docker/Dockerfile + target: tests + environment: + - DOCKER_TESTS=true + - ZIP_ARCHIVE_PASSWORD=password + + backuper_tests_arm64: + restart: "no" + networks: + - backuper + platform: linux/arm64 + build: + context: ./../ + dockerfile: docker/Dockerfile + target: tests + environment: + - DOCKER_TESTS=true + - ZIP_ARCHIVE_PASSWORD=password + +networks: + backuper: \ No newline at end of file