From 04dbe4c705e45dfeaa91c6fee951fb9a6cb2221a Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Fri, 11 Oct 2024 17:54:37 -0300 Subject: [PATCH 1/4] Add --add-opens=java.desktop/sun.java2d.pipe=ALL-UNNAMED to base image Allows to show the current rendering engine in the webui's server status page --- src/apps/base-images/jre/Dockerfile | 12 +----------- src/apps/base-images/spring-boot/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/apps/base-images/jre/Dockerfile b/src/apps/base-images/jre/Dockerfile index 8eeedd1d1..18a0b6d51 100644 --- a/src/apps/base-images/jre/Dockerfile +++ b/src/apps/base-images/jre/Dockerfile @@ -2,15 +2,5 @@ FROM eclipse-temurin:21-jre LABEL maintainer="GeoServer PSC " -ENV JAVA_TOOL_OPTS="\ ---add-exports=java.desktop/sun.awt.image=ALL-UNNAMED \ ---add-opens=java.base/java.lang=ALL-UNNAMED \ ---add-opens=java.base/java.util=ALL-UNNAMED \ ---add-opens=java.base/java.lang.reflect=ALL-UNNAMED \ ---add-opens=java.base/java.text=ALL-UNNAMED \ ---add-opens=java.desktop/java.awt.font=ALL-UNNAMED \ ---add-opens=java.desktop/sun.awt.image=ALL-UNNAMED \ ---add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED \ --Djava.awt.headless=true" - +ENV JAVA_TOOL_OPTS= ENV JAVA_OPTS= diff --git a/src/apps/base-images/spring-boot/Dockerfile b/src/apps/base-images/spring-boot/Dockerfile index dba590c12..4974417b7 100644 --- a/src/apps/base-images/spring-boot/Dockerfile +++ b/src/apps/base-images/spring-boot/Dockerfile @@ -19,13 +19,13 @@ RUN mkdir -p /opt/app/bin WORKDIR /opt/app/bin ENV JAVA_TOOL_OPTS="\ ---add-exports=java.desktop/sun.awt.image=ALL-UNNAMED \ --add-opens=java.base/java.lang=ALL-UNNAMED \ --add-opens=java.base/java.util=ALL-UNNAMED \ --add-opens=java.base/java.lang.reflect=ALL-UNNAMED \ --add-opens=java.base/java.text=ALL-UNNAMED \ --add-opens=java.desktop/java.awt.font=ALL-UNNAMED \ --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED \ +--add-opens=java.desktop/sun.java2d.pipe=ALL-UNNAMED \ --add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED \ -Djava.awt.headless=true" From f1f7c7be985a8f69105b1d0a2ae63feca1bd64d4 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Fri, 11 Oct 2024 18:44:31 -0300 Subject: [PATCH 2/4] Replace JAVA_TOOL_OPTS by the more standard JAVA_TOOL_OPTIONS env variable --- Makefile | 28 +++++++++++++-------- docker-build/base-images-multiplatform.yml | 8 +++--- docker-build/base-images.yml | 8 +++--- docker-build/templates.yml | 2 +- src/apps/base-images/jre/Dockerfile | 2 +- src/apps/base-images/spring-boot/Dockerfile | 6 +++-- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 19c6312f4..b4f2d9d69 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ TAG=$(shell mvn help:evaluate -Dexpression=project.version -q -DforceStdout) COSIGN_PASSWORD := $(COSIGN_PASSWORD) + REPACKAGE ?= true .PHONY: clean @@ -36,25 +37,34 @@ build-image: build-base-images build-image-infrastructure build-image-geoserver .PHONY: build-base-images build-base-images: package-base-images - TAG=$(TAG) docker compose -f docker-build/base-images.yml build + COMPOSE_DOCKER_CLI_BUILD=0 DOCKER_BUILDKIT=0 TAG=$(TAG) \ + docker compose -f docker-build/base-images.yml build jre \ + && COMPOSE_DOCKER_CLI_BUILD=0 DOCKER_BUILDKIT=0 TAG=$(TAG) \ + docker compose -f docker-build/base-images.yml build spring-boot \ + && COMPOSE_DOCKER_CLI_BUILD=0 DOCKER_BUILDKIT=0 TAG=$(TAG) \ + docker compose -f docker-build/base-images.yml build geoserver-common .PHONY: build-image-infrastructure build-image-infrastructure: package-infrastructure-images - TAG=$(TAG) docker compose -f docker-build/infrastructure.yml build + COMPOSE_DOCKER_CLI_BUILD=0 DOCKER_BUILDKIT=0 TAG=$(TAG) \ + docker compose -f docker-build/infrastructure.yml build .PHONY: build-image-geoserver build-image-geoserver: package-geoserver-images - TAG=$(TAG) docker compose -f docker-build/geoserver.yml build + COMPOSE_DOCKER_CLI_BUILD=0 DOCKER_BUILDKIT=0 TAG=$(TAG) \ + docker compose -f docker-build/geoserver.yml build .PHONY: build-image-multiplatform build-image-multiplatform: build-base-images-multiplatform build-image-infrastructure-multiplatform build-image-geoserver-multiplatform .PHONY: build-base-images-multiplatform build-base-images-multiplatform: package-base-images - COMPOSE_DOCKER_CLI_BUILD=1 \ - DOCKER_BUILDKIT=1 \ - TAG=$(TAG) \ - docker compose -f docker-build/base-images-multiplatform.yml build --push + COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 TAG=$(TAG) \ + docker compose -f docker-build/base-images-multiplatform.yml build jre --push \ + && COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 TAG=$(TAG) \ + docker compose -f docker-build/base-images-multiplatform.yml build spring-boot --push \ + && COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 TAG=$(TAG) \ + docker compose -f docker-build/base-images-multiplatform.yml build geoserver-common --push .PHONY: build-image-infrastructure-multiplatform build-image-infrastructure-multiplatform: package-infrastructure-images @@ -65,9 +75,7 @@ build-image-infrastructure-multiplatform: package-infrastructure-images .PHONY: build-image-geoserver-multiplatform build-image-geoserver-multiplatform: package-geoserver-images - COMPOSE_DOCKER_CLI_BUILD=1 \ - DOCKER_BUILDKIT=1 \ - TAG=$(TAG) \ + COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 TAG=$(TAG) \ docker compose -f docker-build/geoserver-multiplatform.yml build --push .PHONY: package-base-images diff --git a/docker-build/base-images-multiplatform.yml b/docker-build/base-images-multiplatform.yml index 58d728caa..a3956b72f 100644 --- a/docker-build/base-images-multiplatform.yml +++ b/docker-build/base-images-multiplatform.yml @@ -1,5 +1,5 @@ services: - base-image-jre: + jre: extends: file: templates.yml service: multi-platform @@ -7,20 +7,18 @@ services: build: context: ../src/apps/base-images/jre/ - base-image-spring-boot: + spring-boot: extends: file: templates.yml service: multi-platform image: ${REPOSITORY}/gs-cloud-base-spring-boot:${TAG} - depends_on: [base-image-jre] build: context: ../src/apps/base-images/spring-boot/ - base-image-geoserver: + geoserver-common: extends: file: templates.yml service: multi-platform image: ${REPOSITORY}/gs-cloud-base-geoserver-image:${TAG} - depends_on: [base-image-spring-boot] build: context: ../src/apps/base-images/geoserver/ diff --git a/docker-build/base-images.yml b/docker-build/base-images.yml index bf51d8a90..49b95aa63 100644 --- a/docker-build/base-images.yml +++ b/docker-build/base-images.yml @@ -1,5 +1,5 @@ services: - base-image-jre: + jre: extends: file: templates.yml service: current-platform @@ -7,20 +7,18 @@ services: build: context: ../src/apps/base-images/jre/ - base-image-spring-boot: + spring-boot: extends: file: templates.yml service: current-platform image: ${REPOSITORY}/gs-cloud-base-spring-boot:${TAG} - depends_on: [base-image-jre] build: context: ../src/apps/base-images/spring-boot/ - base-image-geoserver: + geoserver-common: extends: file: templates.yml service: current-platform image: ${REPOSITORY}/gs-cloud-base-geoserver-image:${TAG} - depends_on: [base-image-spring-boot] build: context: ../src/apps/base-images/geoserver/ diff --git a/docker-build/templates.yml b/docker-build/templates.yml index f3a42495a..c827e50a2 100644 --- a/docker-build/templates.yml +++ b/docker-build/templates.yml @@ -2,7 +2,7 @@ services: current-platform: build: no_cache: true - pull: true + pull: false context: override-me args: TAG: ${TAG} diff --git a/src/apps/base-images/jre/Dockerfile b/src/apps/base-images/jre/Dockerfile index 18a0b6d51..674227ff0 100644 --- a/src/apps/base-images/jre/Dockerfile +++ b/src/apps/base-images/jre/Dockerfile @@ -2,5 +2,5 @@ FROM eclipse-temurin:21-jre LABEL maintainer="GeoServer PSC " -ENV JAVA_TOOL_OPTS= +ENV JAVA_TOOL_OPTIONS= ENV JAVA_OPTS= diff --git a/src/apps/base-images/spring-boot/Dockerfile b/src/apps/base-images/spring-boot/Dockerfile index 4974417b7..aece11e76 100644 --- a/src/apps/base-images/spring-boot/Dockerfile +++ b/src/apps/base-images/spring-boot/Dockerfile @@ -18,7 +18,9 @@ RUN mkdir -p /opt/app/bin WORKDIR /opt/app/bin -ENV JAVA_TOOL_OPTS="\ +# default JVM parameters https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html +# to add JVM parameters use the JAVA_OPTS env variable preferrably +ENV JAVA_TOOL_OPTIONS="\ --add-opens=java.base/java.lang=ALL-UNNAMED \ --add-opens=java.base/java.util=ALL-UNNAMED \ --add-opens=java.base/java.lang.reflect=ALL-UNNAMED \ @@ -44,4 +46,4 @@ HEALTHCHECK \ --retries=5 \ CMD curl -f -s -o /dev/null localhost:8081/actuator/health || exit 1 -CMD exec env USER_ID="$(id -u)" USER_GID="$(id -g)" java $JAVA_OPTS $JAVA_TOOL_OPTS org.springframework.boot.loader.JarLauncher +CMD exec env USER_ID="$(id -u)" USER_GID="$(id -g)" java $JAVA_OPTS org.springframework.boot.loader.JarLauncher From a3880c498995e6cc3460347d6701068833b6bbe9 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Fri, 11 Oct 2024 19:32:25 -0300 Subject: [PATCH 3/4] Parameterize the docker "repository" for the dev compose Allow to test locally by pushing/pulling to/from another account, e.g.: ``` REPOSITORY=groldan make build-multiplatform-image ``` will tag and push images as `groldan/xxx:` --- .github/workflows/pull-request.yaml | 8 ++++--- compose/.env | 3 +++ compose/compose.yml | 22 ++++++++++---------- compose/infra.yml | 2 +- docker-build/base-images.yml | 1 + src/apps/base-images/spring-boot/Dockerfile | 4 ++++ src/apps/geoserver/gwc/Dockerfile | 2 ++ src/apps/geoserver/restconfig/Dockerfile | 2 ++ src/apps/geoserver/wcs/Dockerfile | 2 ++ src/apps/geoserver/webui/Dockerfile | 2 ++ src/apps/geoserver/wfs/Dockerfile | 2 ++ src/apps/geoserver/wms/Dockerfile | 2 ++ src/apps/geoserver/wps/Dockerfile | 2 ++ src/apps/infrastructure/admin/Dockerfile | 2 ++ src/apps/infrastructure/config/Dockerfile | 2 ++ src/apps/infrastructure/discovery/Dockerfile | 2 ++ src/apps/infrastructure/gateway/Dockerfile | 2 ++ 17 files changed, 47 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 5a1406717..a0cea05fa 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -84,24 +84,26 @@ jobs: - name: Copy config directory # during the validate phase, the config/ dir is copied to each app's target/config - run: ./mvnw validate -ntp -T1C + run: ./mvnw validate -f src/apps -ntp -T1C - name: Build images # REPACKAGE=false avoids to re-package the apps during build-image run: REPACKAGE=false make build-image - name: Install CI dependencies + id: install-ci run: python3 -m pip install --user --requirement=ci/requirements.txt - name: Run acceptance tests ${{ matrix.catalog }} + id: acceptance run: | make acceptance-tests-${{ matrix.catalog }} - name: Print docker compose logs - if: always() + if: steps.build.install-ci == 'success' run: (cd compose && c2cciutils-docker-logs) - name: Cleanup acceptance tests - if: always() + if: steps.build.acceptance != 'skipped' run: | make clean-acceptance-tests-${{ matrix.catalog }} diff --git a/compose/.env b/compose/.env index 946408862..ad0a8bfa1 100644 --- a/compose/.env +++ b/compose/.env @@ -1,6 +1,9 @@ # docker-compose default environment variable values +REPOSITORY=geoservercloud TAG=1.9-SNAPSHOT +ACL_REPOSITORY=geoservercloud ACL_TAG=2.3.1 + GS_USER="1000:1000" GATEWAY_SHARED_AUTH=true diff --git a/compose/compose.yml b/compose/compose.yml index fa73d14cf..0cb8a0834 100644 --- a/compose/compose.yml +++ b/compose/compose.yml @@ -27,7 +27,7 @@ x-gs-dependencies: &gs-dependencies services: acl: - image: geoservercloud/geoserver-acl:${ACL_TAG} + image: ${ACL_REPOSITORY}/geoserver-acl:${ACL_TAG} environment: # Override default values in the container's /etc/geoserver/acl-service.yml - PG_HOST=acldb @@ -65,7 +65,7 @@ services: # microservices. Being a Discovery First Bootstrap configuration, it'll # register itself with the Eureka discovery service and can be scaled config: - image: geoservercloud/geoserver-cloud-config:${TAG} + image: ${REPOSITORY}/geoserver-cloud-config:${TAG} user: ${GS_USER} environment: JAVA_OPTS: "${JAVA_OPTS_CONFIG}" @@ -90,7 +90,7 @@ services: # The discovery service is the only fixed entry point. # Browse to http://localhost:8761 to check all services are registered. discovery: - image: geoservercloud/geoserver-cloud-discovery:${TAG} + image: ${REPOSITORY}/geoserver-cloud-discovery:${TAG} user: ${GS_USER} environment: JAVA_OPTS: "${JAVA_OPTS_DISCOVERY}" @@ -109,7 +109,7 @@ services: # Application facade, provides a single entry point routing to all # microservices (e.g. http://localhost:9090/geoserver/wms, http://localhost:9090/geoserver/wfs, etc) gateway: - image: geoservercloud/geoserver-cloud-gateway:${TAG} + image: ${REPOSITORY}/geoserver-cloud-gateway:${TAG} user: ${GS_USER} depends_on: discovery: @@ -132,13 +132,13 @@ services: extends: file: templates.yml service: gstemplate - image: geoservercloud/geoserver-cloud-wfs:${TAG} + image: ${REPOSITORY}/geoserver-cloud-wfs:${TAG} environment: JAVA_OPTS: "${JAVA_OPTS_WFS}" depends_on: *gs-dependencies wms: - image: geoservercloud/geoserver-cloud-wms:${TAG} + image: ${REPOSITORY}/geoserver-cloud-wms:${TAG} extends: file: templates.yml service: gstemplate @@ -150,7 +150,7 @@ services: extends: file: templates.yml service: gstemplate - image: geoservercloud/geoserver-cloud-wcs:${TAG} + image: ${REPOSITORY}/geoserver-cloud-wcs:${TAG} environment: JAVA_OPTS: "${JAVA_OPTS_WCS}" depends_on: *gs-dependencies @@ -159,7 +159,7 @@ services: extends: file: templates.yml service: gstemplate - image: geoservercloud/geoserver-cloud-wps:${TAG} + image: ${REPOSITORY}/geoserver-cloud-wps:${TAG} environment: JAVA_OPTS: "${JAVA_OPTS_WPS}" depends_on: *gs-dependencies @@ -168,7 +168,7 @@ services: extends: file: templates.yml service: gstemplate - image: geoservercloud/geoserver-cloud-gwc:${TAG} + image: ${REPOSITORY}/geoserver-cloud-gwc:${TAG} environment: JAVA_OPTS: "${JAVA_OPTS_GWC}" depends_on: *gs-dependencies @@ -182,7 +182,7 @@ services: extends: file: templates.yml service: gstemplate - image: geoservercloud/geoserver-cloud-rest:${TAG} + image: ${REPOSITORY}/geoserver-cloud-rest:${TAG} environment: JAVA_OPTS: "${JAVA_OPTS_REST}" depends_on: *gs-dependencies @@ -191,7 +191,7 @@ services: extends: file: templates.yml service: gstemplate - image: geoservercloud/geoserver-cloud-webui:${TAG} + image: ${REPOSITORY}/geoserver-cloud-webui:${TAG} environment: JAVA_OPTS: "${JAVA_OPTS_WEBUI}" depends_on: *gs-dependencies diff --git a/compose/infra.yml b/compose/infra.yml index 9e902c664..ab74becb1 100644 --- a/compose/infra.yml +++ b/compose/infra.yml @@ -45,7 +45,7 @@ services: retries: 3 admin: - image: geoservercloud/geoserver-cloud-admin-server:${TAG} + image: ${REPOSITORY}/geoserver-cloud-admin-server:${TAG} user: ${GS_USER} depends_on: discovery: diff --git a/docker-build/base-images.yml b/docker-build/base-images.yml index 49b95aa63..a6a6a9274 100644 --- a/docker-build/base-images.yml +++ b/docker-build/base-images.yml @@ -5,6 +5,7 @@ services: service: current-platform image: ${REPOSITORY}/gs-cloud-base-jre:${TAG} build: + pull: true context: ../src/apps/base-images/jre/ spring-boot: diff --git a/src/apps/base-images/spring-boot/Dockerfile b/src/apps/base-images/spring-boot/Dockerfile index aece11e76..bbffd5b53 100644 --- a/src/apps/base-images/spring-boot/Dockerfile +++ b/src/apps/base-images/spring-boot/Dockerfile @@ -36,7 +36,11 @@ EXPOSE 8080 EXPOSE 8081 COPY --from=builder dependencies/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder snapshot-dependencies/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder spring-boot-loader/ ./ HEALTHCHECK \ diff --git a/src/apps/geoserver/gwc/Dockerfile b/src/apps/geoserver/gwc/Dockerfile index 851d7cbb6..35f9293be 100644 --- a/src/apps/geoserver/gwc/Dockerfile +++ b/src/apps/geoserver/gwc/Dockerfile @@ -17,4 +17,6 @@ FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/geoserver/restconfig/Dockerfile b/src/apps/geoserver/restconfig/Dockerfile index 851d7cbb6..35f9293be 100644 --- a/src/apps/geoserver/restconfig/Dockerfile +++ b/src/apps/geoserver/restconfig/Dockerfile @@ -17,4 +17,6 @@ FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/geoserver/wcs/Dockerfile b/src/apps/geoserver/wcs/Dockerfile index 851d7cbb6..35f9293be 100644 --- a/src/apps/geoserver/wcs/Dockerfile +++ b/src/apps/geoserver/wcs/Dockerfile @@ -17,4 +17,6 @@ FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/geoserver/webui/Dockerfile b/src/apps/geoserver/webui/Dockerfile index 851d7cbb6..35f9293be 100644 --- a/src/apps/geoserver/webui/Dockerfile +++ b/src/apps/geoserver/webui/Dockerfile @@ -17,4 +17,6 @@ FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/geoserver/wfs/Dockerfile b/src/apps/geoserver/wfs/Dockerfile index 851d7cbb6..35f9293be 100644 --- a/src/apps/geoserver/wfs/Dockerfile +++ b/src/apps/geoserver/wfs/Dockerfile @@ -17,4 +17,6 @@ FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/geoserver/wms/Dockerfile b/src/apps/geoserver/wms/Dockerfile index 851d7cbb6..35f9293be 100644 --- a/src/apps/geoserver/wms/Dockerfile +++ b/src/apps/geoserver/wms/Dockerfile @@ -17,4 +17,6 @@ FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/geoserver/wps/Dockerfile b/src/apps/geoserver/wps/Dockerfile index 851d7cbb6..35f9293be 100644 --- a/src/apps/geoserver/wps/Dockerfile +++ b/src/apps/geoserver/wps/Dockerfile @@ -17,4 +17,6 @@ FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/infrastructure/admin/Dockerfile b/src/apps/infrastructure/admin/Dockerfile index 2e6762f69..bb8b79e07 100644 --- a/src/apps/infrastructure/admin/Dockerfile +++ b/src/apps/infrastructure/admin/Dockerfile @@ -16,6 +16,8 @@ FROM $REPOSITORY/gs-cloud-base-spring-boot:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ HEALTHCHECK \ diff --git a/src/apps/infrastructure/config/Dockerfile b/src/apps/infrastructure/config/Dockerfile index 0c1a0e3fb..96538ff7d 100644 --- a/src/apps/infrastructure/config/Dockerfile +++ b/src/apps/infrastructure/config/Dockerfile @@ -16,6 +16,8 @@ FROM $REPOSITORY/gs-cloud-base-spring-boot:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ # Where jgit will try to create a .config directory diff --git a/src/apps/infrastructure/discovery/Dockerfile b/src/apps/infrastructure/discovery/Dockerfile index d16b5892c..7a3d9206f 100644 --- a/src/apps/infrastructure/discovery/Dockerfile +++ b/src/apps/infrastructure/discovery/Dockerfile @@ -16,4 +16,6 @@ FROM $REPOSITORY/gs-cloud-base-spring-boot:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ diff --git a/src/apps/infrastructure/gateway/Dockerfile b/src/apps/infrastructure/gateway/Dockerfile index d16b5892c..7a3d9206f 100644 --- a/src/apps/infrastructure/gateway/Dockerfile +++ b/src/apps/infrastructure/gateway/Dockerfile @@ -16,4 +16,6 @@ FROM $REPOSITORY/gs-cloud-base-spring-boot:$TAG COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +#see https://github.com/moby/moby/issues/37965 +RUN true COPY --from=builder application/ ./ From d9394b91ef9d7d78d4f5c0fb7c2180cd5c54fdde Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Mon, 14 Oct 2024 22:23:39 -0300 Subject: [PATCH 4/4] Split acceptance test execution into start and run phases Regularly, you'd keep on running `make acceptance-tests-[datadir|pgconfig|jdbcconfig]` as usual. For the github action it's nicer to have the docker compo start and run in separte steps. --- .github/workflows/pull-request.yaml | 36 +++++++++++---------- Makefile | 50 ++++++++++++++++++++--------- compose/acceptance.yml | 14 ++++++++ 3 files changed, 68 insertions(+), 32 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index a0cea05fa..db42a654f 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -50,7 +50,9 @@ jobs: uses: actions/upload-artifact@v4 with: name: application-jars - path: ./**/target/*-bin.jar + path: | + ./**/target/*-bin.jar + ./**/target/config/ retention-days: 1 compression-level: 0 # no compression @@ -63,18 +65,13 @@ jobs: strategy: fail-fast: false matrix: - catalog: [ 'datadir', 'pgconfig', 'jdbcconfig' ] + catalog: [ 'datadir' ] + #catalog: [ 'datadir', 'pgconfig', 'jdbcconfig' ] steps: - name: Checkout uses: actions/checkout@v4 with: submodules: recursive - - name: Set up java - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' - cache: 'maven' - name: Download application jar files uses: actions/download-artifact@v4 @@ -82,28 +79,33 @@ jobs: name: application-jars path: . - - name: Copy config directory - # during the validate phase, the config/ dir is copied to each app's target/config - run: ./mvnw validate -f src/apps -ntp -T1C - - name: Build images # REPACKAGE=false avoids to re-package the apps during build-image run: REPACKAGE=false make build-image + - name: Build acceptance tests docker image + run: | + make build-acceptance + - name: Install CI dependencies - id: install-ci + id: installci run: python3 -m pip install --user --requirement=ci/requirements.txt - - name: Run acceptance tests ${{ matrix.catalog }} + - name: Launch ${{ matrix.catalog }} acceptance tests docker composition + id: start + run: | + make start-acceptance-tests-${{ matrix.catalog }} + + - name: Run ${{ matrix.catalog }} acceptance tests id: acceptance run: | - make acceptance-tests-${{ matrix.catalog }} + make run-acceptance-tests-${{ matrix.catalog }} - name: Print docker compose logs - if: steps.build.install-ci == 'success' + if: always() run: (cd compose && c2cciutils-docker-logs) - name: Cleanup acceptance tests - if: steps.build.acceptance != 'skipped' + if: always() run: | make clean-acceptance-tests-${{ matrix.catalog }} diff --git a/Makefile b/Makefile index b4f2d9d69..e507a40a3 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,11 @@ install: .PHONY: package package: - ./mvnw clean package -DskipTests -ntp -U -T1C + ./mvnw clean package -Dfmt.skip -DskipTests -ntp -U -T1C .PHONY: test test: - ./mvnw verify -ntp -T1C + ./mvnw verify -Dfmt.skip -ntp -T1C .PHONY: build-image build-image: build-base-images build-image-infrastructure build-image-geoserver @@ -136,19 +136,16 @@ verify-image: build-acceptance: docker build --tag=acceptance:$(TAG) acceptance_tests -.PHONY: acceptance-tests-pgconfig -acceptance-tests-pgconfig: build-acceptance - (cd compose/ && ./acceptance_pgconfig up -d) - (cd compose/ && ./acceptance_pgconfig exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes') - -.PHONY: clean-acceptance-tests-pgconfig -clean-acceptance-tests-pgconfig: - (cd compose/ && ./acceptance_pgconfig down -v) - .PHONY: acceptance-tests-datadir -acceptance-tests-datadir: build-acceptance +acceptance-tests-datadir: build-acceptance start-acceptance-tests-datadir run-acceptance-tests-datadir + +.PHONY: start-acceptance-tests-datadir +start-acceptance-tests-datadir: (cd compose/ && ./acceptance_datadir up -d) - (cd compose/ && ./acceptance_datadir exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes') + +.PHONY: run-acceptance-tests-datadir +run-acceptance-tests-datadir: + (cd compose/ && ./acceptance_datadir run --rm -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes') .PHONY: clean-acceptance-tests-datadir clean-acceptance-tests-datadir: @@ -156,10 +153,33 @@ clean-acceptance-tests-datadir: rm -rf compose/catalog-datadir/* touch compose/catalog-datadir/.keep +.PHONY: acceptance-tests-pgconfig +acceptance-tests-pgconfig: build-acceptance start-acceptance-tests-pgconfig run-acceptance-tests-pgconfig + (cd compose/ && ./acceptance_pgconfig up -d) + (cd compose/ && ./acceptance_pgconfig exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes') + +.PHONY: start-acceptance-tests-pgconfig +start-acceptance-tests-pgconfig: + (cd compose/ && ./acceptance_pgconfig up -d) + +.PHONY: run-acceptance-tests-pgconfig +run-acceptance-tests-pgconfig: + (cd compose/ && ./acceptance_pgconfig run --rm -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes') + +.PHONY: clean-acceptance-tests-pgconfig +clean-acceptance-tests-pgconfig: + (cd compose/ && ./acceptance_pgconfig down -v) + .PHONY: acceptance-tests-jdbcconfig -acceptance-tests-jdbcconfig: build-acceptance +acceptance-tests-jdbcconfig: build-acceptance start-acceptance-tests-jdbcconfig run-acceptance-tests-jdbcconfig + +.PHONY: start-acceptance-tests-jdbcconfig +start-acceptance-tests-jdbcconfig: (cd compose/ && ./acceptance_jdbcconfig up -d) - (cd compose/ && ./acceptance_jdbcconfig exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes') + +.PHONY: run-acceptance-tests-jdbcconfig +run-acceptance-tests-jdbcconfig: + (cd compose/ && ./acceptance_jdbcconfig run --rm -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes') .PHONY: clean-acceptance-tests-jdbcconfig clean-acceptance-tests-jdbcconfig: diff --git a/compose/acceptance.yml b/compose/acceptance.yml index f1244be38..155e3e155 100644 --- a/compose/acceptance.yml +++ b/compose/acceptance.yml @@ -13,6 +13,13 @@ services: interval: 30s timeout: 10s retries: 5 + deploy: + mode: replicated + replicas: 1 + resources: + limits: + cpus: "1.0" + memory: 512M acceptance: image: acceptance:${TAG} @@ -39,6 +46,13 @@ services: condition: service_healthy acl: condition: service_started + deploy: + mode: replicated + replicas: 0 + resources: + limits: + cpus: "1.0" + memory: 512M # For github CI acl: