Skip to content

Commit

Permalink
Update base image of Dockerfile (OpenAPITools#17007)
Browse files Browse the repository at this point in the history
* Update base image of Dockerfile

* Make github workflow "Docker tests" manually triggerable

* Don't possibly downgrade TLS version

* Update Dockerimage in ``run-in-docker.sh``

* Use Maven's non interactive mode inside workflow

* Don't spam log

* Use java 17

because it won't compile with 21

* Removed hard memory limit

as memory should be controlled by the container

* Update hub dockerfiles
  • Loading branch information
litetex authored and Javier Puerto committed Nov 14, 2023
1 parent 25e749d commit 5c0ea58
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Docker tests

on:
workflow_dispatch:
push:
paths:
- Dockerfile
Expand All @@ -27,7 +28,7 @@ jobs:
shell: bash
run: |
sed -i 's/ -it / /g' run-in-docker.sh
./run-in-docker.sh mvn clean install
./run-in-docker.sh mvn -B clean install
- name: Build Dockerfile
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .hub.cli.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
##
## You can build _just_ this part with:
## docker --target builder -t container-name:builder -f .hub.cli.dockerfile .
FROM maven:3.6.3-jdk-11-openj9 as builder
FROM maven:3-eclipse-temurin-17 as builder

ENV GEN_DIR /opt/openapi-generator
WORKDIR ${GEN_DIR}
COPY . ${GEN_DIR}

# Pre-compile openapi-generator-cli
RUN mvn -am -pl "modules/openapi-generator-cli" package
RUN mvn -B -am -pl "modules/openapi-generator-cli" package

## The final (release) image
## The resulting container here only needs the target jar
## and ca-certificates (to be able to query HTTPS hosted specs)
FROM openjdk:11.0.8-jre-slim-buster
FROM eclipse-temurin:17-jre

ENV GEN_DIR /opt/openapi-generator

Expand Down
6 changes: 3 additions & 3 deletions .hub.online.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
##
## You can build _just_ this part with:
## docker --target builder -t container-name:builder -f .hub.online.dockerfile .
FROM maven:3.6.3-jdk-11-openj9 as builder
FROM maven:3-eclipse-temurin-17 as builder

ENV GEN_DIR /opt/openapi-generator
WORKDIR ${GEN_DIR}
COPY . ${GEN_DIR}

# Pre-compile openapi-generator-online
RUN mvn -am -pl "modules/openapi-generator-online" package
RUN mvn -B -am -pl "modules/openapi-generator-online" package

## The final (release) image
## The resulting container here only needs the target jar
FROM openjdk:11.0.8-jre-slim-buster
FROM eclipse-temurin:17-jre

ENV GEN_DIR /opt/openapi-generator
ENV TARGET_DIR /generator
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM maven:3.6.3-jdk-11-openj9
FROM maven:3-eclipse-temurin-17

ENV GEN_DIR /opt/openapi-generator
WORKDIR ${GEN_DIR}
Expand All @@ -20,7 +20,7 @@ COPY ./modules/openapi-generator ${GEN_DIR}/modules/openapi-generator
COPY ./pom.xml ${GEN_DIR}

# Pre-compile openapi-generator-cli
RUN mvn -am -pl "modules/openapi-generator-cli" package
RUN mvn -B -am -pl "modules/openapi-generator-cli" package

# This exists at the end of the file to benefit from cached layers when modifying docker-entrypoint.sh.
COPY docker-entrypoint.sh /usr/local/bin/
Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

# GEN_DIR allows to share the entrypoint between Dockerfile and run-in-docker.sh (backward compatible)
GEN_DIR=${GEN_DIR:-/opt/openapi-generator}
JAVA_OPTS=${JAVA_OPTS:-"-Xmx1024M -DloggerPath=conf/log4j.properties"}
JAVA_OPTS=${JAVA_OPTS:-"-DloggerPath=conf/log4j.properties"}

cli="${GEN_DIR}/modules/openapi-generator-cli"
codegen="${cli}/target/openapi-generator-cli.jar"
Expand Down
4 changes: 2 additions & 2 deletions run-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ docker run --rm -it \
-w /gen \
-e GEN_DIR=/gen \
-e MAVEN_CONFIG=/var/maven/.m2 \
-e MAVEN_OPTS="-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=/var/maven/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Djacoco.skip=true" \
-e MAVEN_OPTS="-Dmaven.repo.local=/var/maven/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Djacoco.skip=true" \
-u "$(id -u):$(id -g)" \
-v "${PWD}:/gen" \
-v "${PWD}/CI/run-in-docker-settings.xml:/var/maven/.m2/settings.xml" \
-v "${maven_cache_repo}:/var/maven/.m2/repository" \
--entrypoint /gen/docker-entrypoint.sh \
maven:3-jdk-11 "$@"
maven:3-eclipse-temurin-17 "$@"

0 comments on commit 5c0ea58

Please sign in to comment.