Files
tide-display/backend/Dockerfile
Peter Siegmund c4ccf27130 starting backend
Signed-off-by: Peter Siegmund <peter@rdkr.com>
2024-05-30 14:26:45 +02:00

31 lines
1009 B
Docker

# Stage that builds the application, a prerequisite for the running stage
FROM eclipse-temurin:21-jdk-jammy as build
ARG SERVICE_ROOT
RUN apt-get update -qq
# Stop running as root at this point
RUN useradd -m tide
WORKDIR /usr/src/app/
RUN chown tide:tide /usr/src/app/
USER tide
# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies
COPY --chown=tide ${SERVICE_ROOT}/.mvn/ .mvn
COPY --chown=tide ${SERVICE_ROOT}/mvnw ${SERVICE_ROOT}/pom.xml ./
# Copy all needed project files to a folder
COPY --chown=tide:tide ${SERVICE_ROOT}/src ./src
# Build the production package, assuming that we validated the version before so no need for running tests again
RUN ./mvnw --batch-mode clean package -DskipTests
# Running stage: the part that is used for running the application
FROM eclipse-temurin:21-jre-jammy
COPY --from=build /usr/src/app/target/*.jar /usr/app/app.jar
RUN useradd -m tide
USER tide
EXPOSE 8080
CMD java -jar /usr/app/app.jar