-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile.prod
More file actions
41 lines (29 loc) · 897 Bytes
/
Copy pathdockerfile.prod
File metadata and controls
41 lines (29 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
FROM eclipse-temurin:17-jdk-jammy
# Install ffmpeg
RUN apt-get update && \
apt-get install -y ffmpeg && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create user and group for security
RUN addgroup --system spring && adduser --system spring --ingroup spring
# Set working directory
WORKDIR /app
# Copy Maven wrapper and pom.xml first (for better layer caching)
COPY .mvn/ .mvn/
COPY mvnw pom.xml ./
# Download dependencies (cached layer if pom.xml doesn't change)
RUN ./mvnw dependency:go-offline
# Copy source code
COPY src ./src
# Build the application
RUN ./mvnw package -DskipTests
# Copy the built JAR to a simpler name
RUN cp target/videoplayer-0.0.1-SNAPSHOT.jar app.jar
# Change ownership to spring user
RUN chown -R spring:spring /app
# Switch to non-root user
USER spring
# Expose port
EXPOSE 8081
# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]