-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.test
More file actions
61 lines (53 loc) · 2.43 KB
/
Copy pathDockerfile.test
File metadata and controls
61 lines (53 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# c2c test environment — sealed container for e2e integration testing.
#
# Multi-stage build:
# Stage 1 (builder): builds c2c binary from source.
# Stage 2 (test-runner): debian slim + binary + Python + pytest.
#
# Usage:
# docker build -f Dockerfile.test -t c2c-test:latest .
# docker compose -f docker-compose.test.yml run --rm test-env pytest tests/
#
# Auth files (kimi, etc.) mounted at runtime via compose volumes.
# Broker state is ephemeral (anonymous volume — fresh each run).
ARG CACHE_BUST=1
ARG OCAML_VERSION=5.2
FROM ocaml/opam:debian-12-ocaml-${OCAML_VERSION} AS builder
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake pkg-config libgmp-dev libssl-dev \
libev-dev zlib1g-dev libsqlite3-dev git \
&& rm -rf /var/lib/apt/lists/*
USER opam
WORKDIR /home/opam/c2c
RUN opam update -y \
&& opam install --yes \
dune cmdliner yojson lwt logs cohttp-lwt-unix uuidm sqlite3 \
base64 digestif mirage-crypto-ec mirage-crypto-rng mirage-crypto-rng-lwt \
tls-lwt ca-certs conduit-lwt-unix x509 ptime hacl-star \
"lambda-term" "zed" "uucp"
# Copy source — --chown changes ownership of the copied tree to opam:opam.
COPY dune-project ./
COPY ocaml ./ocaml
# Remove any stale _build dir from the host (wrong uid causes Permission denied)
USER root
RUN rm -rf /home/opam/c2c/_build && chown -R opam:opam /home/opam/c2c
USER opam
RUN opam exec -- dune build --release ocaml/cli/c2c.exe
# ----------------------------------------------------------------------
FROM python:3.12-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates libgmp10 libssl3 libev4 libsqlite3-0 tini curl openssh-client inotify-tools sudo git tmux \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --system --home /home/testagent --shell /usr/sbin/nologin testagent \
&& mkdir -p /home/testagent /var/lib/c2c \
&& chown -R testagent /home/testagent /var/lib/c2c \
&& pip install --no-cache-dir pytest pytest-timeout \
&& rm -rf /var/cache/pip
COPY --from=builder /home/opam/c2c/_build/default/ocaml/cli/c2c.exe /usr/local/bin/c2c
RUN chmod +x /usr/local/bin/c2c
COPY docker-tests/ /docker-tests/
# tini = PID 1 signal forwarder
ENTRYPOINT ["/usr/bin/tini", "--"]
# Default command: keep container alive for `docker compose up -d` (tests use `run --rm` override).
CMD ["sh", "-c", "echo c2c-test ready && sleep 3600"]