diff --git a/Dockerfile b/Dockerfile index c3229f1..b3c5774 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,14 @@ -# Stage that builds the application, a prerequisite for the running stage -FROM maven:3-openjdk-17-slim as build -RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - -RUN apt-get update -qq && apt-get install -qq --no-install-recommends nodejs - -# Stop running as root at this point -RUN useradd -m myuser -WORKDIR /usr/src/app/ -RUN chown myuser:myuser /usr/src/app/ -USER myuser - -# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies -COPY --chown=myuser pom.xml ./ -RUN mvn dependency:go-offline -Pproduction - -# Copy all needed project files to a folder -COPY --chown=myuser:myuser src src -COPY --chown=myuser:myuser frontend frontend -COPY --chown=myuser:myuser package.json ./ - -# Using * after the files that are autogenerated so that so build won't fail if they are not yet created -COPY --chown=myuser:myuser package-lock.json* pnpm-lock.yaml* webpack.config.js* ./ - - -# Build the production package, assuming that we validated the version before so no need for running tests again -RUN mvn clean package -DskipTests -Pproduction - -# Running stage: the part that is used for running the application -FROM openjdk:17-jdk-slim -COPY --from=build /usr/src/app/target/*.jar /usr/app/app.jar -RUN useradd -m myuser -USER myuser -EXPOSE 8080 -CMD java -jar /usr/app/app.jar +FROM adoptopenjdk:11-jre-hotspot as builder +ARG JAR_FILE=trainerinvoice*.jar +COPY ${JAR_FILE} application.jar +RUN java -Djarmode=layertools -jar application.jar extract + +FROM adoptopenjdk:11-jre-hotspot +RUN echo "Europe/Berlin" > /etc/timezone +COPY --from=builder dependencies/ ./ +COPY --from=builder snapshot-dependencies/ ./ +COPY --from=builder spring-boot-loader/ ./ +COPY --from=builder application/ ./ +ENV JAVA_OPTS="-Duser.language=de -Duser.country=DE -Duser.region=DE" +ENV TZ=Europe/Berlin +ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..790b44d --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,32 @@ +version: '2' +services: + trainerinvoice: + image: markuskreth/trainerinvoice + container_name: trainerinvoice + build: . + restart: unless-stopped + expose: + - "" + networks: + - + environment: + - VIRTUAL_HOST= + - VIRTUAL_PORT= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + - KEYCLOAK_AUTH-SERVER-URL= + - KEYCLOAK_REALM= + - KEYCLOAK_RESOURCE= + - KEYCLOAK_CREDENTIALS_SECRET= + - SERVER_PORT= + - SPRING_DATASOURCE_URL=jdbc:postgresql://:/ + - SPRING_DATASOURCE_USERNAME= + - SPRING_DATASOURCE_PASSWORD= + - LANG=de_DE.UTF-8 + - LANGUAGE=de_DE:de + - LC_ALL=de_DE.UTF-8 + - logging.level.root=INFO + - logging.level.de.kreth=DEBUG +networks: + : + external: true diff --git a/pom.xml b/pom.xml index bd66325..a226568 100644 --- a/pom.xml +++ b/pom.xml @@ -186,11 +186,19 @@ org.springframework.boot spring-boot-maven-plugin + the default Spring Boot's 30sec timeout. --> + de.kreth.invoice.Application 500 240 + + + + repackage + + +