Fork me on GitHub
#docker
<
2020-01-26
>
Chris08:01:56

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"]

Chris08:01:02

Which can also be deployed on a server

Chris08:01:15

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

Chris08:01:59

Which uses the same dockerfile but instead of using the jar that was built, it just uses lein ring server-headless

Chris08:01:52

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 …

Chris08:01:32

Hope that clears up the confusion 🙂

Chris08:01:12

Maybe my approach is not so good, I don’t know …