#+TITLE: Containerizing your application This is a multistage Dockerfile it has a build and run stage to help reduce the final image size. This example is built for use with polylith it allows you to build multiple containers from a single docker file. #+BEGIN_SRC yaml :tangle src/core.cljc # Beware the alpine images, seems the googleads library does not like the alphine glib alternative ie muscl FROM clojure:temurin-17-tools-deps AS builder ENV CLOJURE_VERSION=1.11.1.1182 ARG PROJECT RUN mkdir -p /build WORKDIR /build # Fetch the deps first, by copying just the deps we can cache the download # except when the deps file has changed. COPY ./deps.edn /build RUN clojure -P -X:dev COPY ./ /build RUN clojure -T:build uberjar :project $PROJECT FROM eclipse-temurin:17 ARG PROJECT COPY --from=builder /build/target/ /app WORKDIR /app ADD ./projects/car-cli/resources/google/ /app/ ADD ./projects/car-cli/resources/google/ /root/ RUN mkdir -p /app/environment/ # Build ARG are not available at runtime but we can insert them into env as part of the build ENV PROJECT_RUN=/app/${PROJECT}.jar ENTRYPOINT ["java", "-jar"] # this is expanded by a shell so can't use in a params list, can't find another way CMD java -jar ${PROJECT_RUN}.jar #+END_SRC #+BEGIN_SRC sh :tangle src/core.cljc docker build -f Dockerfile-Multistage . --build-arg PROJECT=example-api #+END_SRC