So this is currently my Dockerfile:
FROM clojure:openjdk-8-lein
WORKDIR /usr/src/app
COPY project.clj /usr/src/app/
RUN lein deps
COPY . /usr/src/app
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" /usr/bin/app-standalone.jar
CMD ["java", "-jar", "/usr/bin/app-standalone.jar"]
Which can also be deployed on a server
This is my docker-compose.yml
version: '3'
services:
app:
build: .
ports:
- "8080:8080"
- "47480:47480"
environment:
LEIN_REPL_HOST: "0.0.0.0"
LEIN_REPL_PORT: 47480
PORT: 8080
command: >
sh -c "lein migrate && lein ring server-headless"
volumes:
- .:/usr/src/app
Which uses the same dockerfile but instead of using the jar that was built, it just uses lein ring server-headless
The problem is, that the commands:
COPY project.clj /usr/src/app/
RUN lein deps
do not install the plugins that are needed in the docker-compose.yml. Therefore on each fresh docker-compose up
the plugins are installed …Hope that clears up the confusion 🙂
Maybe my approach is not so good, I don’t know …