TextPurify/API/Dockerfile

30 lines
576 B
Docker
Raw Permalink Normal View History

2024-06-19 19:31:07 -07:00
# Stage 1: Build
FROM maven:3.8.5-openjdk-17-slim AS build
2024-06-19 19:06:10 -07:00
2024-06-20 20:54:50 -07:00
WORKDIR /usr/local/app
2024-06-19 19:06:10 -07:00
2024-06-19 19:31:07 -07:00
# Copy only the files needed for the build
COPY pom.xml ./
COPY src ./src
2024-06-19 19:06:10 -07:00
# Build the app
RUN mvn clean package -q -DskipTests -T4C
2024-06-19 19:31:07 -07:00
# Stage 2: Runtime
FROM openjdk:17-jdk-slim
2024-06-20 20:54:50 -07:00
WORKDIR /usr/local/app
2024-06-19 19:31:07 -07:00
# Copy the jar from the build stage
2024-06-20 20:54:50 -07:00
COPY --from=build /usr/local/app/target/TextPurify-API.jar ./TextPurify-API.jar
2024-06-19 19:31:07 -07:00
# Expose port
2024-06-19 19:06:10 -07:00
EXPOSE 80
2024-06-19 19:31:07 -07:00
# Set environment variables
ENV HOSTNAME="0.0.0.0"
ENV PORT=80
ENV APP_ENV="production"
2024-06-19 19:06:10 -07:00
# Start the app
2024-06-19 19:31:07 -07:00
CMD ["java", "-jar", "TextPurify-API.jar"]