diff --git a/Dockerfile b/Dockerfile index eec20d0ace..b3e50c7412 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM gradle:6.9.3-jdk11 AS builder -RUN apt-get update && \ +RUN --mount=type=cache,target=/var/cache,sharing=locked \ + --mount=type=cache,target=/root/.cache \ + apt-get update && \ apt-get install --yes --no-install-recommends fonts-liberation gettext curl && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* && \ gradle --version WORKDIR /src @@ -15,26 +15,30 @@ COPY docs/build.gradle ./docs/ COPY publish/build.gradle ./publish/ COPY core ./core -RUN gradle :core:processResources :core:classes +RUN --mount=type=cache,target=/home/gradle/.gradle \ + gradle :core:processResources :core:classes COPY checkstyle_* ./ # '&& touch success || true' is a trick to be able to get out some artifacts -RUN gradle :core:checkstyleMain :core:spotbugsMain :core:violations --stacktrace \ - && ( (gradle :core:build :core:explodedWar :core:libSourcesJar :core:libJavadocJar && touch success) || true) +RUN --mount=type=cache,target=/home/gradle/.gradle \ + (gradle :core:checkstyleMain :core:spotbugsMain :core:violations --stacktrace > /tmp/logs 2>&1) \ + && ( (gradle :core:build :core:explodedWar :core:libSourcesJar :core:libJavadocJar && touch success) || true) ARG GIT_HEAD ENV GIT_HEAD=${GIT_HEAD} COPY publish ./publish -RUN ([ -e success ] && (gradle :publish:build && touch success-publish)) || true +RUN --mount=type=cache,target=/home/gradle/.gradle \ + ([ -e success ] && ( (gradle :publish:build >> /tmp/logs 2>&1) && touch success-publish)) || true COPY examples ./examples COPY docs ./docs -RUN ([ -e success ] && (gradle :examples:build buildDocs && touch success-examples-docs)) || true +RUN --mount=type=cache,target=/home/gradle/.gradle \ + ([ -e success ] && ( (gradle :examples:build buildDocs >> /tmp/logs 2>&1) && touch success-examples-docs)) || true FROM builder AS test-builder -RUN [ -e success ] && [ -e success-publish ] && [ -e success-examples-docs ] +RUN cat /tmp/logs && [ -e success ] && [ -e success-publish ] && [ -e success-examples-docs ] VOLUME [ "/src/core" ] diff --git a/Makefile b/Makefile index a8ae3612d3..0281bc7e03 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ GIT_HEAD_ARG = --build-arg=GIT_HEAD=$(shell git rev-parse HEAD) -export DOCKER_BUILDKIT = 0 +export DOCKER_BUILDKIT = 1 .PHONY: build build: diff --git a/README.md b/README.md index dc0a6e1878..fb52cded58 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ Execute the following command(): > make build ``` -This will build three artifacts: print-servlet-xxx.war, print-lib.jar, print-standalone.jar +This will build three artifacts: `print-servlet-xxx.war`, `print-lib.jar`, `print-standalone.jar`. The build also builds the documentation in the docs/build/site folder. To deploy the documentation it should -simply be copied to the gh-pages branch and then committed GitHub will automatically build the updated site +simply be copied to the `gh-pages` branch and then committed GitHub will automatically build the updated site at: If you only want to build the docs simply run: @@ -35,7 +35,7 @@ The test (part of the build) requires the 'Liberation Sans' font, which can be d -# Auto-reload mode +# Debug mode To be able to quickly test modifications in the print you should: @@ -43,11 +43,14 @@ To be able to quickly test modifications in the print you should: - Run `docker compose up -d`, The print will be available on port `8080` and on code modification will be built and trigger a restart. -# Create new stabilisation branch +With that you will have a running print, when you modify the code the print will be rebuilt and restarted, +and the debugging port will be opened on `5005`. + +# Create new stabilization branch - Update `CHANGELOG.md` - Create a new branch name `x.y` from master. -- Create a new label names `backport x.y` in the right color (GitHub: Issues->Labels->New Label). +- Create a new label names `backport x.y` in the right color (GitHub: Issues -> Labels -> New Label). - Create a tag `x.y.0`. - On the master branch: Update the `SECURITY.md` file, add a policy for the new and old version. - On the master branch update the `.github/workflows/rebuild.yaml` file by adding the new branch name. @@ -76,7 +79,7 @@ If you want to run in debug mode you can do the following: For the examples that use GeoServer you should run it in the composition, then build and start the composition: -``` +```bash make build cp docker-compose.override.sample.yaml docker-compose.override.yaml make acceptance-tests-up @@ -84,7 +87,7 @@ make acceptance-tests-up Run the example: -``` +```bash docker-compose exec builder gradle print -PprintArgs="-config /src/examples/src/test/resources/examples/simple/config.yaml -spec /src/examples/src/test/resources/examples/simple/requestData.json -output /src/examples/output.pdf" ``` @@ -101,8 +104,8 @@ Import project into Eclipse # Run in Eclipse - Create new Java Run Configuration -- Main class is org.mapfish.print.cli.Main -- Program arguments: -config samples/config.yaml -spec samples/spec.json -output \$HOME/print.pdf +- Main class is `org.mapfish.print.cli.Main` +- Program arguments: `-config samples/config.yaml -spec samples/spec.json -output \$HOME/print.pdf` # Contributor License Agreement diff --git a/core/Dockerfile b/core/Dockerfile index e5b6366b96..461db74b0b 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -3,7 +3,9 @@ FROM mapfish_print_builder AS builder FROM tomcat:9.0.62-jdk17-openjdk-slim-bullseye AS runner LABEL maintainer="Camptocamp " -RUN perl -0777 -i -pe 's/(]*>)//s' "${CATALINA_HOME}/conf/server.xml" \ +RUN --mount=type=cache,target=/var/cache,sharing=locked \ + --mount=type=cache,target=/root/.cache \ + perl -0777 -i -pe 's/(]*>)//s' "${CATALINA_HOME}/conf/server.xml" \ && echo "tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*" >> "${CATALINA_HOME}/conf/catalina.properties" \ && echo "org.apache.catalina.startup.TldConfig.jarsToSkip=*" >> "${CATALINA_HOME}/conf/catalina.properties" \ && echo "tomcat.util.scan.DefaultJarScanner.jarsToSkip=*" >> "${CATALINA_HOME}/conf/catalina.properties" \ @@ -15,9 +17,7 @@ RUN perl -0777 -i -pe 's/( - diff --git a/docker-compose.override.sample.yaml b/docker-compose.override.sample.yaml index 2c75974461..9981fbdff5 100644 --- a/docker-compose.override.sample.yaml +++ b/docker-compose.override.sample.yaml @@ -18,3 +18,9 @@ services: - /usr/local/tomcat/bin/docker-start-watch volumes_from: - builder + ports: + - 5005:5005 + environment: + CATALINA_OUT: /dev/stdout + CATALINA_PID: /usr/local/tomcat/bin/catalina.pid + JAVA_OPTS: -Dsun.net.inetaddr.ttl=30 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 diff --git a/docker-compose.yaml b/docker-compose.yaml index 99d7e37474..130e990515 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,11 +17,10 @@ services: PRINT_YAML_MAX_ALIASES: 200 LOG_LEVEL: DEBUG JASPER_LOG_LEVEL: DEBUG - CATALINA_OUT: /dev/stdout tests: image: mapfish_print_builder - command: sleep infinity + command: tail --follow /dev/null volumes: - ./examples/src/test/resources/examples:/src/examples/src/test/resources/examples environment: diff --git a/gradle.properties b/gradle.properties index 5f4361051c..b0c02d5b18 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ enablePublishing=false group=org.mapfish.print version=1.0.0 +org.gradle.caching=true