diff --git a/backend/Dockerfile b/backend/Dockerfile index 1faff516..5ab5b167 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,32 +1,43 @@ ### Builder -FROM ghcr.io/graalvm/native-image:22.3.3 AS build +FROM eclipse-temurin:17.0.8.1_1-jdk-jammy AS build + +# Install Maven +RUN apt update -y && \ + apt install -y wget tar && \ + wget https://archive.apache.org/dist/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz && \ + tar xzf apache-maven-3.8.6-bin.tar.gz -C /opt && \ + ln -s /opt/apache-maven-3.8.6 /opt/maven && \ + ln -s /opt/maven/bin/mvn /usr/bin/mvn && \ + rm apache-maven-3.8.6-bin.tar.gz && \ + apt-get clean + +# Add Maven to the PATH environment variable +ENV MAVEN_HOME=/opt/maven +ENV PATH=$MAVEN_HOME/bin:$PATH + +# Receiving app version +ARG APP_VERSION=0.0.1 # Copy WORKDIR /app -COPY pom.xml mvnw ./ +COPY pom.xml ./ COPY src ./src -COPY .mvn/ ./.mvn -COPY InstallCert.java . # Build -RUN ./mvnw package -Pnative -DskipTests -Dskip.unit.tests=true -Dspring-boot.run.profiles=prod +RUN mvn clean package -DskipTests -Dtests.skip=true -Dskip.unit.tests=true ### Deployer -FROM eclipse-temurin:17.0.12_7-jdk-jammy AS deploy +FROM eclipse-temurin:17.0.8.1_1-jre-jammy AS deploy +ARG PORT=3100 # Copy WORKDIR /app -COPY --from=build /app/target/*.jar /app/*.class ./artifacts/ -COPY dockerfile-entrypoint.sh ./ -RUN mkdir config dump public && \ - chmod -R g+w . && \ - chmod g+x dockerfile-entrypoint.sh && \ - chmod g+w ${JAVA_HOME}/lib/security/cacerts - -# Port and health check +COPY --from=build /app/target/nr-results-backend.jar ./nr-results-backend.jar + +# User, port and health check USER 1001 -EXPOSE 8080 -HEALTHCHECK CMD curl -f http://localhost:8080/actuator/health | grep '"status":"UP"' +EXPOSE ${PORT} +HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' # Startup -ENTRYPOINT ["/app/dockerfile-entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["java", "-jar","/app/nr-results-backend.jar","--spring.profiles.active=prod"] \ No newline at end of file