nuthatch/Dockerfile

93 lines
4.1 KiB
Docker

FROM node:24.18.1-bookworm-slim AS frontend
WORKDIR /web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web ./
RUN npm test && npm run check && npm run build
FROM haskell:9.10.3-slim-bookworm AS build
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libpq-dev \
pkg-config \
zlib1g-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY nuthatch.cabal cabal.project cabal.project.freeze LICENSE ./
RUN cabal update \
&& cabal build --only-dependencies all
COPY sql ./sql
COPY app ./app
COPY src ./src
COPY test ./test
RUN cabal build exe:nuthatch exe:nuthatch-storage-integration exe:nuthatch-recovery-probe exe:nuthatch-protocol-conformance exe:nuthatch-runtime-probe exe:nuthatch-auth-probe exe:nuthatch-product-probe exe:nuthatch-idempotency-probe exe:nuthatch-streaming-probe exe:nuthatch-runtime-http-probe exe:nuthatch-runtime-audit-probe exe:nuthatch-fixture-probe exe:nuthatch-dependency-probe \
&& mkdir -p /out \
&& cp "$(cabal list-bin exe:nuthatch)" /out/nuthatch \
&& cp "$(cabal list-bin exe:nuthatch-storage-integration)" /out/nuthatch-storage-integration \
&& cp "$(cabal list-bin exe:nuthatch-recovery-probe)" /out/nuthatch-recovery-probe \
&& cp "$(cabal list-bin exe:nuthatch-protocol-conformance)" /out/nuthatch-protocol-conformance \
&& cp "$(cabal list-bin exe:nuthatch-runtime-probe)" /out/nuthatch-runtime-probe \
&& cp "$(cabal list-bin exe:nuthatch-auth-probe)" /out/nuthatch-auth-probe \
&& cp "$(cabal list-bin exe:nuthatch-product-probe)" /out/nuthatch-product-probe \
&& cp "$(cabal list-bin exe:nuthatch-idempotency-probe)" /out/nuthatch-idempotency-probe \
&& cp "$(cabal list-bin exe:nuthatch-streaming-probe)" /out/nuthatch-streaming-probe \
&& cp "$(cabal list-bin exe:nuthatch-runtime-http-probe)" /out/nuthatch-runtime-http-probe \
&& cp "$(cabal list-bin exe:nuthatch-runtime-audit-probe)" /out/nuthatch-runtime-audit-probe \
&& cp "$(cabal list-bin exe:nuthatch-fixture-probe)" /out/nuthatch-fixture-probe \
&& cp "$(cabal list-bin exe:nuthatch-dependency-probe)" /out/nuthatch-dependency-probe
FROM debian:bookworm-slim AS runtime-base
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libpq5 \
ca-certificates \
openssl \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --system --gid 10001 nuthatch \
&& useradd --system --uid 10001 --gid 10001 --no-create-home nuthatch
WORKDIR /app
COPY sql ./sql
COPY --from=frontend /web/dist ./web/dist
COPY LICENSE THIRD_PARTY_NOTICES.txt /usr/share/doc/nuthatch/
RUN dpkg-query --show --showformat='${binary:Package}\t${Version}\n' \
| sort > /usr/share/doc/nuthatch/debian-packages.txt
USER 10001:10001
FROM runtime-base AS test-runtime
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
USER 10001:10001
COPY --from=build /out/nuthatch /usr/local/bin/nuthatch
COPY --from=build /out/nuthatch-storage-integration /usr/local/bin/nuthatch-storage-integration
COPY --from=build /out/nuthatch-recovery-probe /usr/local/bin/nuthatch-recovery-probe
COPY --from=build /out/nuthatch-protocol-conformance /usr/local/bin/nuthatch-protocol-conformance
COPY --from=build /out/nuthatch-runtime-probe /usr/local/bin/nuthatch-runtime-probe
COPY --from=build /out/nuthatch-auth-probe /usr/local/bin/nuthatch-auth-probe
COPY --from=build /out/nuthatch-product-probe /usr/local/bin/nuthatch-product-probe
COPY --from=build /out/nuthatch-idempotency-probe /usr/local/bin/nuthatch-idempotency-probe
COPY --from=build /out/nuthatch-streaming-probe /usr/local/bin/nuthatch-streaming-probe
COPY --from=build /out/nuthatch-runtime-http-probe /usr/local/bin/nuthatch-runtime-http-probe
COPY --from=build /out/nuthatch-runtime-audit-probe /usr/local/bin/nuthatch-runtime-audit-probe
COPY --from=build /out/nuthatch-fixture-probe /usr/local/bin/nuthatch-fixture-probe
COPY --from=build /out/nuthatch-dependency-probe /usr/local/bin/nuthatch-dependency-probe
CMD ["nuthatch"]
FROM runtime-base AS runtime
COPY --from=build /out/nuthatch /usr/local/bin/nuthatch
EXPOSE 8080
CMD ["nuthatch"]