From d1c740ae8d829f9b08a84714b3b3ad69d385a75f Mon Sep 17 00:00:00 2001 From: michaelchin Date: Thu, 25 Jan 2024 15:05:01 +1100 Subject: [PATCH] add test-docker-compose.yml --- .github/workflows/build-and-push-docker.yml | 8 ++- .github/workflows/test-docker-compose.yml | 33 +++++++++++ .github/workflows/test.yml | 25 ++++++++ docker/docker-compose-mc.yml | 65 +++++++++++++++++++++ docker/docker-compose.yml | 24 -------- docker/gws-amd64/Dockerfile | 2 +- docker/gws-arm64/Dockerfile | 2 +- 7 files changed, 130 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/test-docker-compose.yml create mode 100644 docker/docker-compose-mc.yml diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index c3e09ee..48721f7 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -26,21 +26,23 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push GWS amd64 - if: false uses: docker/build-push-action@v5 with: context: . file: ./docker/gws-amd64/Dockerfile push: true + platforms: linux/amd64 + provenance: false tags: gplates/gws:amd64-${{github.ref_name}} - name: Build and push GWS arm64 - if: false uses: docker/build-push-action@v5 with: context: . file: ./docker/gws-arm64/Dockerfile push: true + platforms: linux/arm64 + provenance: false tags: gplates/gws:arm64-${{github.ref_name}} - name: Build and push PostGIS amd64 @@ -66,5 +68,5 @@ jobs: name: Create cross-platform images run: | docker buildx imagetools create -t gplates/postgis:${{github.ref_name}} gplates/postgis:amd64-${{github.ref_name}} gplates/postgis:arm64-${{github.ref_name}} -# docker buildx imagetools create -t gplates/gws:${{github.ref_name}} gplates/gws:amd64-${{github.ref_name}} gplates/gws:arm64-${{github.ref_name}} + docker buildx imagetools create -t gplates/gws:${{github.ref_name}} gplates/gws:amd64-${{github.ref_name}} gplates/gws:arm64-${{github.ref_name}} diff --git a/.github/workflows/test-docker-compose.yml b/.github/workflows/test-docker-compose.yml new file mode 100644 index 0000000..bf14fc0 --- /dev/null +++ b/.github/workflows/test-docker-compose.yml @@ -0,0 +1,33 @@ +name: Test Docker Compose + +on: + release: + types: [published] + +jobs: + test-docker-compose: + runs-on: ubuntu-latest + + steps: + - + name: Start Docker compose + run: | + cd docker + docker-compose up -d + - + name: Sleep for 30 seconds + run: sleep 30s + shell: bash + - + name: Check Docker compose + if: always() + run: | + docker ps + docker network ls + docker inspect gws -f "{{json .NetworkSettings.Networks }}" + wget http://localhost:18000 + curl --fail -s http://localhost:18000/raster/query?lon=128.86&lat=-12.42&raster_name=crustal_thickness + + + + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f31d674..9a3d850 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,5 +78,30 @@ jobs: if: always() run: | docker exec gws cat /var/log/apache2/error.log + + test-docker-compose: + runs-on: ubuntu-latest + + steps: + - + name: Start Docker compose + run: | + cd docker + docker-compose up -d + - + name: Sleep for 30 seconds + run: sleep 30s + shell: bash + - + name: Check Docker compose + if: always() + run: | + docker ps + docker network ls + docker inspect gws -f "{{json .NetworkSettings.Networks }}" + wget http://localhost:18000 + curl --fail -s http://localhost:18000/raster/query?lon=128.86&lat=-12.42&raster_name=crustal_thickness + + diff --git a/docker/docker-compose-mc.yml b/docker/docker-compose-mc.yml new file mode 100644 index 0000000..5a43f39 --- /dev/null +++ b/docker/docker-compose-mc.yml @@ -0,0 +1,65 @@ +# This is for Michael Chin only... +version: '3.9' + +volumes: + gws-code: + external: true + name: gws-code + gws-db-data: + external: true + name: gws-db-data-new + +services: + gws-postgis: + image: gplates/postgis + networks: + - gws-net + hostname: gws-postgis + volumes: + - gws-db-data:/var/lib/postgresql/15/main + ports: + - 5432:5432 + environment: + - POSTGRES_PASSWORD="this is not a real password! go away!" + restart: on-failure + healthcheck: + test: pg_isready -U gplates -d gplates + interval: 1m30s + timeout: 10s + retries: 3 + + gws: + image: gplates/gws + networks: + - gws-net + hostname: gws + depends_on: + - gws-postgis + - gws-redis + volumes: + - gws-code:/gws + ports: + - 18000:80 + restart: on-failure + healthcheck: + test: curl --fail -s "http://localhost:80/raster/query?lon=128.86&lat=-12.42&raster_name=crustal_thickness" || exit 1 + interval: 1m30s + timeout: 10s + retries: 3 + + gws-redis: + image: redis + networks: + - gws-net + hostname: gws-redis + restart: on-failure + healthcheck: + test: redis-cli -h gws-redis ping + interval: 1m30s + timeout: 10s + retries: 3 + + +networks: + gws-net: + external: true diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 05a28a3..8c9e7bf 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,23 +1,9 @@ version: '3.9' -volumes: - gws-code: - external: true - name: gws-code - gws-db-data: - external: true - name: gws-db-data-new - services: gws-postgis: image: gplates/postgis - networks: - - gws-net hostname: gws-postgis - volumes: - - gws-db-data:/var/lib/postgresql/15/main - ports: - - 5432:5432 environment: - POSTGRES_PASSWORD="this is not a real password! go away!" restart: on-failure @@ -29,14 +15,10 @@ services: gws: image: gplates/gws - networks: - - gws-net hostname: gws depends_on: - gws-postgis - gws-redis - volumes: - - gws-code:/gws ports: - 18000:80 restart: on-failure @@ -48,8 +30,6 @@ services: gws-redis: image: redis - networks: - - gws-net hostname: gws-redis restart: on-failure healthcheck: @@ -58,7 +38,3 @@ services: timeout: 10s retries: 3 - -networks: - gws-net: - external: true diff --git a/docker/gws-amd64/Dockerfile b/docker/gws-amd64/Dockerfile index 4e0ef53..cdf5a77 100644 --- a/docker/gws-amd64/Dockerfile +++ b/docker/gws-amd64/Dockerfile @@ -53,7 +53,7 @@ RUN pip3 install plate-model-manager --upgrade RUN pip3 install redis ADD . /gws - +RUN mv /gws/django/GWS/env.template /gws/django/GWS/.env RUN pmm download all /gws/django/GWS/data/model-repo/ # Add Tini diff --git a/docker/gws-arm64/Dockerfile b/docker/gws-arm64/Dockerfile index c3a0976..1930d68 100644 --- a/docker/gws-arm64/Dockerfile +++ b/docker/gws-arm64/Dockerfile @@ -53,7 +53,7 @@ RUN pip3 install plate-model-manager --upgrade RUN pip3 install redis ADD . /gws - +RUN mv /gws/django/GWS/env.template /gws/django/GWS/.env RUN pmm download all /gws/django/GWS/data/model-repo/ # Add Tini