Files
google-service/Dockerfile
Peter Siegmund 31ad26a9d7
Some checks failed
deploy to hetzner / deploy (push) Failing after 11m40s
optimize setup
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2025-08-23 00:11:47 +02:00

34 lines
1.1 KiB
Docker

# Stage that builds the application, a prerequisite for the running stage
FROM eclipse-temurin:21-jdk-noble AS build
RUN apt-get update -qq
# Stop running as root at this point
RUN useradd -m app
WORKDIR /usr/src/app/
RUN chown app:app /usr/src/app/
USER app
# Copy all needed project files to a folder
COPY --chown=app ./gradle/ ./gradle
COPY --chown=app ./gradlew ./build.gradle ./settings.gradle ./
COPY --chown=app ./src ./src
RUN curl -OL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
# Build the production package
RUN ./gradlew clean build -x test
# Running stage: the part that is used for running the application
FROM eclipse-temurin:21-jre-noble
RUN useradd -m app
USER app
COPY --chown=app --from=build /usr/src/app/build/libs/*-SNAPSHOT.jar /usr/app/google.jar
COPY --chown=app --from=build /usr/src/app/opentelemetry-javaagent.jar /usr/app/opentelemetry-javaagent.jar
HEALTHCHECK CMD curl --fail http://localhost:8080/actuator/health || exit 1
CMD ["java", "-jar", "/usr/app/google.jar"]