diff --git a/Dockerfile b/Dockerfile index 22523ac..b26d9aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ # The base image. +# FROM eclipse-temurin:21-jdk-jammy as builder FROM eclipse-temurin:21-jdk-alpine # The work directory. @@ -8,6 +9,10 @@ WORKDIR / ENV PORT=9090 EXPOSE $PORT +# Copy the source code into the Docker image. +# Docker uses caching to speed up builds by reusing layers from previous builds. +# To take advantage of caching, you should order your Dockerfile instructions so that the ones that change frequently are placed towards the end of the file. +# For example, if you’re copying files into the image, you should do that at the end of the Dockerfile. # The JAR file path. # ARG JAR_FILE=*.jar # ARG JAR_FILE=the-review-room-0.0.1-SNAPSHOT.jar @@ -15,7 +20,6 @@ EXPOSE $PORT # Copy the JAR file from the build context into the Docker image. # COPY target/${JAR_FILE} application.jar -# Copy the source code into the Docker image. COPY .mvn/ .mvn COPY mvnw pom.xml ./ @@ -24,11 +28,19 @@ COPY src ./src # Modify the permissions of the mvnw script. RUN chmod +x ./mvnw -# CMD apk update \ -# && rm -rf /var/cache/apk/* +# RUN apk add --no-cache \ +# package1 \ +# package2 \ +# package3 && \ +# rm -rf /var/cache/apk/* /tmp/* + +# RUN apt-get update && \ +# rm -rf /var/lib/apt/lists/* + +# RUN apt-get update && \ +# apt-get install -y postgresql postgresql-contrib && \ +# rm -rf /var/lib/apt/lists/* -# Set the default command to run the Java application. -#ENTRYPOINT ["java", "-Xmx2048M", "-jar", "/application.jar"] -# ENTRYPOINT ["java","-jar","/application.jar"] +# Compile the Java application. RUN ./mvnw install -DskipTests CMD ["./mvnw", "spring-boot:run"]