docker

Chris 2020-01-26T08:39:56.008700Z

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

Chris 2020-01-26T08:41:02.009700Z

Which can also be deployed on a server

Chris 2020-01-26T08:41:15.010Z

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

Chris 2020-01-26T08:41:59.010800Z

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

Chris 2020-01-26T08:42:52.011900Z

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 …

Chris 2020-01-26T08:43:32.012200Z

Hope that clears up the confusion 🙂

Chris 2020-01-26T08:44:12.013Z

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