-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (46 loc) · 1.45 KB
/
Dockerfile
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# FROM maven:3.8.6-openjdk-18 AS build
#
# # Set the working directory inside the Docker container
# WORKDIR /app
#
# # Copy the entire project directory into the working directory
# COPY . /app
#
# # Run the Maven build
# RUN mvn clean package -DskipTests
#
# FROM eclipse-temurin:latest
#
# # Copy the jar file to the runtime image
# COPY --from=build /app/target/Shopy-0.0.1-SNAPSHOT.jar app.jar
#
# # Expose the port
# EXPOSE 8080
#
# # Run the jar file
# # ENTRYPOINT ["java", "-Dserver.port=$PORT", "-jar", "/app.jar"]
# ENTRYPOINT ["java", "-Xmx512m", "-jar", "/app.jar"]
# Use an Azul Zulu OpenJDK 22 image for the build stage
FROM azul/zulu-openjdk-debian:22.0.0 AS build
# Set the working directory inside the container
WORKDIR /app
# Install Maven
RUN apt-get update && apt-get install -y maven
# Copy the Maven project file
COPY Shopy/pom.xml .
# Download and cache the dependencies
RUN mvn dependency:go-offline -B
# Copy the entire project
COPY Shopy .
# Build the application
RUN mvn package -DskipTests
# Use the Azul Zulu OpenJDK 22 image for the runtime stage
FROM azul/zulu-openjdk-debian:22.0.0
# Set the working directory inside the container
WORKDIR /app
# Copy the jar file from the build stage
COPY --from=build /app/target/Shopy-0.0.1-SNAPSHOT.jar app.jar
# Expose the port your application runs on (replace 8080 if your app runs on a different port)
EXPOSE 8080
# Set the entry point to run the JAR file
ENTRYPOINT ["java", "-jar", "app.jar"]