Skip to content

Commit

Permalink
Merge pull request #313 from softwareconstruction240/use-multistage-b…
Browse files Browse the repository at this point in the history
…uild

Fix git header issue and use smaller final build
  • Loading branch information
pawlh authored Apr 13, 2024
2 parents 31c073b + 4b1804d commit f45ac14
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,31 @@ RUN apt-get update && \
npm install -g yarn

### install frontend dependencies
COPY ./src/main/resources/frontend/package.json ./src/main/resources/frontend/yarn.lock /app/src/main/resources/frontend/
COPY ./src/main/resources/frontend/package.json ./src/main/resources/frontend/yarn.lock ./src/main/resources/frontend/

RUN cd src/main/resources/frontend && \
yarn

### install backend dependencies
COPY ./pom.xml /app
COPY ./pom.xml .

RUN mvn dependency:go-offline

### build frontend
COPY ./src/main/resources/frontend /app/src/main/resources/frontend
COPY ./src/main/resources/frontend ./src/main/resources/frontend

RUN cd src/main/resources/frontend && \
yarn build

### build backend
COPY . /app
COPY ./src ./src

RUN mvn clean package -DskipTests

FROM maven:3.9.6-amazoncorretto-21-debian-bookworm AS runner

COPY --from=builder /app/target/automatico-1.0-SNAPSHOT.jar /app/target/

EXPOSE 8080

CMD ["java", "-Dlog4j2.configurationFile=log4j.properties", "-Dlog4j2.debug=false", "-jar", "/app/target/automatico-1.0-SNAPSHOT.jar"]

0 comments on commit f45ac14

Please sign in to comment.