Skip to content

Update the CI and deployment to OCaml 5.2.1, Alpine 2.21, opam 2.3, and use BuildKit syntax in the Dockerfile #2831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- macos-latest
- ubuntu-latest
ocaml-compiler:
- "5.2.0"
- "5.2"

steps:
- name: Checkout Repo
Expand All @@ -35,7 +35,7 @@ jobs:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: ${{ matrix.os != 'macos-latest' }}
opam-repositories: |
pin: git+https://github.com/ocaml/opam-repository#c45f5bab71d3589f41f9603daca5acad14df0ab0
pin: git+https://github.com/ocaml/opam-repository#2c9566f0b0de5ab6dad7ce8d22b68a2999a1861f
opam-disable-sandboxing: true

- name: Install system dependencies (Linux)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/debug-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- macos-latest
- ubuntu-latest
ocaml-compiler:
- "5.2.0"
- "5.2"

steps:
- name: Checkout Repo
Expand All @@ -28,7 +28,7 @@ jobs:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: ${{ matrix.os != 'macos-latest' }}
opam-repositories: |
pin: git+https://github.com/ocaml/opam-repository#c45f5bab71d3589f41f9603daca5acad14df0ab0
pin: git+https://github.com/ocaml/opam-repository#2c9566f0b0de5ab6dad7ce8d22b68a2999a1861f
opam-disable-sandboxing: true

- name: Install system dependencies (Linux)
Expand Down
34 changes: 21 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
FROM ocaml/opam:alpine-3.19-ocaml-5.2 AS build
# syntax=docker/dockerfile:1
FROM ocaml/opam:alpine-3.21-ocaml-5.2 AS build
RUN sudo ln -sf /usr/bin/opam-2.3 /usr/bin/opam && opam init --reinit -ni

# Install system dependencies
RUN sudo apk -U upgrade --no-cache && sudo apk add --no-cache \
RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
sudo ln -s /var/cache/apk /etc/apk/cache && \
sudo apk -U upgrade && sudo apk add \
autoconf \
curl-dev \
gmp-dev \
Expand All @@ -11,13 +15,14 @@ RUN sudo apk -U upgrade --no-cache && sudo apk add --no-cache \
openssl-dev

# Branch freeze was opam-repo HEAD at the time of commit
RUN cd ~/opam-repository && git reset --hard c45f5bab71d3589f41f9603daca5acad14df0ab0 && opam update
RUN cd ~/opam-repository && git reset --hard 2c9566f0b0de5ab6dad7ce8d22b68a2999a1861f && opam update

WORKDIR /home/opam

# Install opam dependencies
COPY --chown=opam ocamlorg.opam .
RUN opam install . --deps-only
COPY --chown=opam --link ocamlorg.opam .
RUN --mount=type=cache,target=/home/opam/.opam/download-cache,sharing=locked,uid=1000,gid=1000 \
opam install . --deps-only

# Build project
COPY --chown=opam . .
Expand All @@ -29,21 +34,24 @@ ENV OCAMLORG_PKG_STATE_PATH=package.state \
OCAMLORG_REPO_PATH=opam-repository
RUN touch package.state && ./init-cache package.state

FROM alpine:3.19

RUN apk -U upgrade --no-cache && apk add --no-cache \
FROM alpine:3.21

RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
ln -s /var/cache/apk /etc/apk/cache && \
apk -U upgrade && apk add \
git \
gmp \
libev

COPY --from=build /home/opam/package.state /var/package.state
COPY --from=build /home/opam/opam-repository /var/opam-repository
COPY --from=build /home/opam/_build/default/src/ocamlorg_web/bin/main.exe /bin/server
COPY --from=build --link /home/opam/package.state /var/package.state
COPY --from=build --link /home/opam/opam-repository /var/opam-repository
COPY --from=build --link /home/opam/_build/default/src/ocamlorg_web/bin/main.exe /bin/server

COPY playground/asset playground/asset
COPY --link playground/asset playground/asset

RUN git clone https://github.com/ocaml-web/html-compiler-manuals /manual
ADD data/v2 /v2
ADD --keep-git-dir --link https://github.com/ocaml-web/html-compiler-manuals /manual
COPY --link data/v2 /v2

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

Expand Down
Loading