From 6d86ce6a7c40b3098336315d3f4cbd4b89ace9c8 Mon Sep 17 00:00:00 2001 From: Erik Martin-Dorel Date: Sat, 9 Oct 2021 15:30:25 +0200 Subject: [PATCH] test: Add Dockefile.test-server to repro issue with learn-ocaml.opam --- .github/workflows/build-and-test.yml | 1 + Dockerfile.test-client | 4 +- Dockerfile.test-server | 70 ++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.test-server diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4eabab5ee..9e1f4b144 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -59,6 +59,7 @@ jobs: matrix: dockerfile: - 'Dockerfile.test-client' + - 'Dockerfile.test-server' steps: - name: Check out the repo uses: actions/checkout@v2 diff --git a/Dockerfile.test-client b/Dockerfile.test-client index 32345200a..d3ac9139a 100644 --- a/Dockerfile.test-client +++ b/Dockerfile.test-client @@ -4,7 +4,7 @@ FROM ocaml/opam:alpine-3.13-ocaml-4.12 as compilation LABEL Description="learn-ocaml building" Vendor="OCamlPro" -WORKDIR learn-ocaml +WORKDIR /home/opam/learn-ocaml # Note: don't copy learn-ocaml.opam.locked COPY learn-ocaml-client.opam learn-ocaml.opam ./ @@ -62,4 +62,4 @@ WORKDIR /learnocaml COPY --from=compilation /home/opam/install-prefix/bin/learn-ocaml-client /usr/bin -ENTRYPOINT ["dumb-init","learn-ocaml-client"] +ENTRYPOINT ["dumb-init","/usr/bin/learn-ocaml-client"] diff --git a/Dockerfile.test-server b/Dockerfile.test-server new file mode 100644 index 000000000..efe90b8cd --- /dev/null +++ b/Dockerfile.test-server @@ -0,0 +1,70 @@ +# This Dockerfile is useful for testing purposes +# to ensure learn-ocaml can be built alone from learn-ocaml.opam + +FROM ocaml/opam:alpine-3.13-ocaml-4.12 as compilation +LABEL Description="learn-ocaml building" Vendor="OCamlPro" + +WORKDIR /home/opam/learn-ocaml + +# Note: don't copy learn-ocaml.locked +COPY learn-ocaml.opam learn-ocaml-client.opam ./ +RUN sudo chown -R opam:nogroup . + +ENV OPAMYES true +RUN echo 'archive-mirrors: [ "https://opam.ocaml.org/cache" ]' >> ~/.opam/config \ + && opam repository set-url default http://opam.ocaml.org \ + && opam switch 4.12 \ + && echo 'pre-session-commands: [ "sudo" "apk" "add" depexts ]' >> ~/.opam/config \ + && opam pin add -n -y -k path learn-ocaml . \ + && opam install learn-ocaml --deps-only --locked + +COPY static static +COPY translations translations +COPY src src +COPY scripts scripts +COPY Makefile Makefile +COPY demo-repository demo-repository +COPY dune-project dune-project +COPY dune dune +RUN sudo chown -R opam:nogroup . + +ENV OPAMVERBOSE 1 + +RUN opam install learn-ocaml --destdir /home/opam/install-prefix \ + && ls -l /home/opam/install-prefix/bin/learn-ocaml + + +FROM alpine:3.13 as program + +ARG BUILD_DATE +ARG VCS_BRANCH +ARG VCS_REF + +LABEL org.label-schema.build-date="${BUILD_DATE}" \ + org.label-schema.name="learn-ocaml" \ + org.label-schema.description="learn-ocaml app manager" \ + org.label-schema.url="https://ocaml-sf.org/" \ + org.label-schema.vendor="The OCaml Software Foundation" \ + org.label-schema.version="${VCS_BRANCH}" \ + org.label-schema.vcs-ref="${VCS_REF}" \ + org.label-schema.vcs-url="https://github.com/ocaml-sf/learn-ocaml" \ + org.label-schema.schema-version="1.0" + +RUN apk update \ + && apk add ncurses-libs libev dumb-init git openssl \ + && addgroup learn-ocaml \ + && adduser learn-ocaml -DG learn-ocaml + +VOLUME ["/repository"] +RUN mkdir -p /sync && chown learn-ocaml:learn-ocaml /sync +VOLUME ["/sync"] +EXPOSE 8080 +EXPOSE 8443 + +USER learn-ocaml +WORKDIR /home/learn-ocaml + +COPY --from=compilation /home/opam/install-prefix /usr + +ENTRYPOINT ["dumb-init","/usr/bin/learn-ocaml","--sync-dir=/sync","--repo=/repository"] +CMD ["build","serve"]