# syntax=docker/dockerfile:1
# -- Build stage --
#
# The haskell and debian base images are multi-arch (amd64 + arm64), so this
# Dockerfile works natively on x86-64 as well as ARM64 hosts like the
# Raspberry Pi 5. Building on the Pi itself is slow; see README.md for
# cross-build instructions.
FROM haskell:9.6-slim AS build
# Install Rocq (needed for verified extraction) and build tools
RUN apt-get update && \
apt-get install -y --no-install-recommends \
opam make sed ca-certificates \
libgmp-dev linux-libc-dev pkg-config && \
rm -rf /var/lib/apt/lists/*
RUN opam init --disable-sandboxing --bare -y && \
opam switch create default ocaml-base-compiler.4.14.2 && \
eval $(opam env --switch=default) && \
opam install rocq-core rocq-stdlib -y
WORKDIR /src
# Copy dependency manifests first to cache the resolver/GHC download
COPY stack.yaml stack.yaml.lock darcsweb.cabal Setup.hs LICENSE ./
RUN eval $(opam env --switch=default) && \
stack setup --install-ghc --no-terminal
# Copy sources and build
COPY src/ src/
COPY app/ app/
COPY test/ test/
COPY verified/ verified/
COPY gen/ gen/
RUN eval $(opam env --switch=default) && \
stack build --install-ghc --no-terminal --copy-bins --local-bin-path /usr/local/bin
# -- Runtime stage --
FROM debian:bookworm-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends libgmp10 && \
rm -rf /var/lib/apt/lists/*
COPY --from=build /usr/local/bin/darcsweb /usr/local/bin/darcsweb
COPY static/ /usr/share/darcsweb/static/
COPY <<'EOF' /etc/darcsweb.conf
bind = 0.0.0.0
port = 3000
repos = /srv/darcs
title = DarcsWeb
static = /usr/share/darcsweb/static
EOF
EXPOSE 3000
ENTRYPOINT ["darcsweb", "-c", "/etc/darcsweb.conf"]