spring-petclinic/.devcontainer/Dockerfile

40 lines
778 B
Text
Raw Normal View History

2025-02-03 14:38:10 +01:00
# Build stage
2025-02-03 15:09:34 +01:00
FROM registry.access.redhat.com/ubi8/openjdk-17:latest as builder
2025-02-03 14:38:10 +01:00
2025-02-03 15:16:23 +01:00
# Install required packages
USER root
RUN microdnf install -y tar gzip
# Switch back to default user
USER 1001
2025-02-03 14:38:10 +01:00
WORKDIR /app
# Copy Maven wrapper and POM
2025-02-03 15:16:23 +01:00
COPY --chown=1001:0 .mvn/ .mvn/
COPY --chown=1001:0 mvnw pom.xml ./
RUN chmod +x mvnw
2025-02-03 14:38:10 +01:00
# Download dependencies
RUN ./mvnw dependency:go-offline
# Copy source code
2025-02-03 15:16:23 +01:00
COPY --chown=1001:0 src ./src
2025-02-03 14:38:10 +01:00
# Build the application
RUN ./mvnw package -DskipTests
# Run stage
2025-02-03 15:09:34 +01:00
FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:latest
2025-02-03 14:38:10 +01:00
WORKDIR /app
# Copy the built artifact from builder stage
COPY --from=builder /app/target/*.jar app.jar
# Container runs on port 8080
EXPOSE 8080
# Set the startup command
ENTRYPOINT ["java", "-jar", "app.jar"]