Skip to content

Commit

Permalink
fix: api dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto-hitori committed Feb 16, 2024
1 parent f7ec11a commit c783d47
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
FROM amazoncorretto:17
LABEL authors="dario"

# Install Maven
RUN yum install -y tar which gzip

ENV MAVEN_HOME /usr/share/maven

COPY --from=maven:3.9.6-eclipse-temurin-11 ${MAVEN_HOME} ${MAVEN_HOME}
COPY --from=maven:3.9.6-eclipse-temurin-11 /usr/local/bin/mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh
COPY --from=maven:3.9.6-eclipse-temurin-11 /usr/share/maven/ref/settings-docker.xml /usr/share/maven/ref/settings-docker.xml

RUN ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn

ARG MAVEN_VERSION=3.9.6
ARG USER_HOME_DIR="/root"
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

ENTRYPOINT ["/usr/local/bin/mvn-entrypoint.sh"]
CMD ["mvn"]
FROM maven:3.8.1-openjdk-17 AS build
# Compile api
WORKDIR /api
COPY . /api
WORKDIR /api
RUN mvn install
RUN mvn clean package

FROM amazoncorretto:17 AS runtime
# Copy the compiled jar file from the build stage
ARG DATABASE_USER
ARG DATABASE_PASSWORD
ARG JWT_SECRET
Expand All @@ -28,12 +17,7 @@ ENV DATABASE_URL jdbc:postgresql://WIQ_DB:5432/wiq
ENV DATABASE_USER $DATABASE_USER
ENV DATABASE_PASSWORD $DATABASE_PASSWORD
ENV JWT_SECRET $JWT_SECRET
# Compile api
COPY . /api
WORKDIR /api
RUN mvn install
COPY target/*.jar app.jar
COPY --from=build /api/target/quiz-api-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]


EXPOSE 8080

0 comments on commit c783d47

Please sign in to comment.