Skip to content

Commit 2653b5c

Browse files
committed
Dockerfile: fix style
- don't cache packages to lighten the image.
1 parent bf5fc4a commit 2653b5c

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

Dockerfile

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1-
FROM ocaml/opam:alpine-3.20-ocaml-5.2 as build
1+
FROM ocaml/opam:alpine-3.20-ocaml-5.2 AS build
22

33
# Install system dependencies
4-
RUN sudo apk update && sudo apk add --update libev-dev openssl-dev gmp-dev oniguruma-dev inotify-tools curl-dev autoconf
4+
RUN apk -U upgrade --no-cache && apk add --no-cache \
5+
autoconf \
6+
curl-dev \
7+
gmp-dev \
8+
inotify-tools \
9+
libev-dev \
10+
oniguruma-dev \
11+
openssl-dev
512

613
# Branch freeze was opam-repo HEAD at the time of commit
7-
RUN cd opam-repository && git pull origin c45f5bab71d3589f41f9603daca5acad14df0ab0 && opam update
14+
RUN cd ~/opam-repository && git fetch -q origin master && git reset --hard c45f5bab71d3589f41f9603daca5acad14df0ab0 && opam update
815

916
WORKDIR /home/opam
1017

11-
# Install Opam dependencies
12-
ADD ocamlorg.opam ocamlorg.opam
18+
# Install opam dependencies
19+
COPY --chown=opam --link ocamlorg.opam .
1320
RUN opam install . --deps-only
1421

1522
# Build project
16-
COPY --chown=opam:opam . .
23+
COPY --chown=opam . .
1724
RUN opam exec -- dune build @install --profile=release
1825

1926
# Launch project in order to generate the package state cache
20-
RUN cd opam-repository && git checkout master && git pull origin master && opam update
21-
ENV OCAMLORG_REPO_PATH opam-repository
22-
ENV OCAMLORG_PKG_STATE_PATH package.state
27+
RUN cd ~/opam-repository && git checkout master && opam update
28+
ENV OCAMLORG_PKG_STATE_PATH=package.state \
29+
OCAMLORG_REPO_PATH=opam-repository
2330
RUN touch package.state && ./init-cache package.state
2431

25-
FROM alpine:3.20 as run
2632

27-
RUN apk update && apk add --update libev gmp git
33+
FROM alpine:3.20
2834

29-
RUN chmod -R 755 /var
35+
RUN apk -U upgrade --no-cache && apk add --no-cache \
36+
git \
37+
gmp \
38+
libev
3039

3140
COPY --from=build /home/opam/package.state /var/package.state
3241
COPY --from=build /home/opam/opam-repository /var/opam-repository
@@ -38,12 +47,12 @@ RUN git clone https://github.com/ocaml-web/html-compiler-manuals /manual
3847

3948
RUN git config --global --add safe.directory /var/opam-repository
4049

41-
ENV OCAMLORG_REPO_PATH /var/opam-repository/
42-
ENV OCAMLORG_MANUAL_PATH /manual
43-
ENV OCAMLORG_PKG_STATE_PATH /var/package.state
44-
ENV DREAM_VERBOSITY info
45-
ENV OCAMLORG_HTTP_PORT 8080
50+
ENV DREAM_VERBOSITY=info \
51+
OCAMLORG_HTTP_PORT=8080 \
52+
OCAMLORG_MANUAL_PATH=/manual \
53+
OCAMLORG_PKG_STATE_PATH=/var/package.state \
54+
OCAMLORG_REPO_PATH=/var/opam-repository/
4655

4756
EXPOSE 8080
4857

49-
ENTRYPOINT /bin/server
58+
ENTRYPOINT ["/bin/server"]

0 commit comments

Comments
 (0)