Skip to content

Commit

Permalink
Update Dockerfile to use opam 2
Browse files Browse the repository at this point in the history
A big difference with the previous Dockerfile is that this container
holds the new learn-ocaml program, not the full web-app: it should be
run with a local exercises repository.

This could be used as base for a container including the exercises
though, possibly using Docker multi-stage.

Build the image using `make docker-image`
  • Loading branch information
AltGr authored and yurug committed Jun 27, 2018
1 parent a7d3ce3 commit 103c737
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
31 changes: 17 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
FROM ocaml/opam

RUN cd /home/opam/opam-repository && git pull

RUN opam config exec -- opam update
FROM ocaml/opam2-staging:alpine
LABEL Description="learn-ocaml running container" Vendor="OCamlPro" Version="0.1"

WORKDIR learn-ocaml

COPY src/opam src/opam
COPY scripts/install-opam-deps.sh scripts/install-opam-deps.sh
COPY Makefile Makefile
COPY learn-ocaml.opam .
RUN sudo chown opam:nogroup learn-ocaml.opam

RUN opam config exec -- make build-deps

COPY . .
ENV OPAMYES true
RUN opam switch 4.05
RUN opam pin learn-ocaml . -n
RUN opam depext learn-ocaml
RUN opam install . --deps-only --locked

ADD . .
RUN sudo chown -R opam:nogroup .

RUN opam config exec -- make REPO_DIR=exercises_repository
RUN opam install .

ARG port=8080
ENV port=${port}

EXPOSE 9090
EXPOSE $port

CMD ["/home/opam/learn-ocaml/learnocaml-simple-server.byte", "-port", "9090" ]
CMD ["build","serve"]
ENTRYPOINT ["/bin/bash","-c","opam exec -- learn-ocaml --sync-dir=/sync --repo=/repository --port=${port} \"$@\""]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ update-%-translation: translations/%.pot
opaminstall: build learn-ocaml.install
@opam-installer --prefix `opam var prefix` learn-ocaml.install

docker-image: Dockerfile learn-ocaml.opam
@rm -rf docker
@git clone . docker
@cp Dockerfile docker
@docker build -t learn-ocaml docker
@echo "Use with 'docker run --rm -v \$$PWD/sync:/sync -v \$$PWD:/repository -p PORT:8080 learn-ocaml -- ARGS'"

clean:
@ocp-build clean
-rm -f translations/$*.pot
Expand Down

0 comments on commit 103c737

Please sign in to comment.