changes for support docker-compose

master
Markus Kreth 4 years ago
parent 8ffbf7a635
commit 8e1dd24d23
  1. 48
      Dockerfile
  2. 32
      docker-compose.yaml
  3. 10
      pom.xml

@ -1,34 +1,14 @@
# Stage that builds the application, a prerequisite for the running stage FROM adoptopenjdk:11-jre-hotspot as builder
FROM maven:3-openjdk-17-slim as build ARG JAR_FILE=trainerinvoice*.jar
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - COPY ${JAR_FILE} application.jar
RUN apt-get update -qq && apt-get install -qq --no-install-recommends nodejs RUN java -Djarmode=layertools -jar application.jar extract
# Stop running as root at this point FROM adoptopenjdk:11-jre-hotspot
RUN useradd -m myuser RUN echo "Europe/Berlin" > /etc/timezone
WORKDIR /usr/src/app/ COPY --from=builder dependencies/ ./
RUN chown myuser:myuser /usr/src/app/ COPY --from=builder snapshot-dependencies/ ./
USER myuser COPY --from=builder spring-boot-loader/ ./
COPY --from=builder application/ ./
# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies ENV JAVA_OPTS="-Duser.language=de -Duser.country=DE -Duser.region=DE"
COPY --chown=myuser pom.xml ./ ENV TZ=Europe/Berlin
RUN mvn dependency:go-offline -Pproduction ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
# 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

@ -0,0 +1,32 @@
version: '2'
services:
trainerinvoice:
image: markuskreth/trainerinvoice
container_name: trainerinvoice
build: .
restart: unless-stopped
expose:
- "<WUNSCH_PORT>"
networks:
- <nginx_Network>
environment:
- VIRTUAL_HOST=<Einstellungen für nginx und letsencrype>
- VIRTUAL_PORT=<WUNSCH_PORT>
- LETSENCRYPT_HOST=<Einstellungen für nginx und letsencrype>
- LETSENCRYPT_EMAIL=<Einstellungen für nginx und letsencrype>
- KEYCLOAK_AUTH-SERVER-URL=<Einstellungen für keycloak>
- KEYCLOAK_REALM=<Einstellungen für keycloak>
- KEYCLOAK_RESOURCE=<Einstellungen für keycloak>
- KEYCLOAK_CREDENTIALS_SECRET=<Einstellungen für keycloak>
- SERVER_PORT=<WUNSCH_PORT>
- SPRING_DATASOURCE_URL=jdbc:postgresql://<DBHOST>:<DBPORT>/<DBNAME>
- SPRING_DATASOURCE_USERNAME=<DBUSER>
- SPRING_DATASOURCE_PASSWORD=<DBPASSWORD>
- 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:
<nginx_Network>:
external: true

@ -186,11 +186,19 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<!-- Clean build and startup time for Vaadin apps sometimes may exceed <!-- Clean build and startup time for Vaadin apps sometimes may exceed
the default Spring Boot's 30sec timeout. --> the default Spring Boot's 30sec timeout. -->
<configuration> <configuration>
<mainClass>de.kreth.invoice.Application</mainClass>
<wait>500</wait> <wait>500</wait>
<maxAttempts>240</maxAttempts> <maxAttempts>240</maxAttempts>
</configuration> </configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
<!-- <!--

Loading…
Cancel
Save