Skip to content

Commit

Permalink
Use multi-stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Nov 11, 2024
1 parent d14861f commit 3d7497f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
with:
context: .
file: deploy/Dockerfile
build-args: |
BUILD_VERSION=${{ env.DOCKER_METADATA_OUTPUT_VERSION }}
GIT_SHA=${{ github.sha }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
21 changes: 15 additions & 6 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Stage 1 - collect deps

FROM clojure:temurin-23-tools-deps-noble

WORKDIR /app
Expand All @@ -6,14 +8,21 @@ COPY deps.edn build.clj ./

RUN --mount=type=cache,target=/root/.m2 clojure -T:build copy-deps :target-dir '"deps-jars"'

# Stage 2

FROM eclipse-temurin:23-jdk-noble

ARG BUILD_VERSION
ARG GIT_SHA

WORKDIR /app

COPY --from=0 /app/deps-jars ./deps-jars

ADD res ./res
ADD src ./src
COPY run.sh ./

CMD ["bash", "/app/run.sh"]

# FROM openjdk:11-jre-slim
RUN echo $BUILD_VERSION > VERSION && echo $GIT_SHA > GIT_SHA

# WORKDIR /app

# # COPY --from=0 /app/target/app-standalone.jar ./app.jar
CMD ["bash", "/app/run.sh"]

0 comments on commit 3d7497f

Please sign in to comment.