Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (53 loc) · 2.84 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (53 loc) · 2.84 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
# The areev container image: the `areev` binary and the `areev-sandbox` it
# dispatches `wasm32-areev` plans to, built from one tree so the pair a plan
# relies on is version-matched. `areev` carries the three
# non-default features a container deployment wants — `postgres` (the server
# tier, --db postgres://…?schema=<name>), `postgres-tls` (encryption on that
# DSN, which every managed Postgres requires) and `tls` (native rustls for
# deployments with nowhere to run a terminating proxy).
#
# docker build -t areev .
#
# Build as `areev:latest` deliberately: that is the image name
# `areev trigger render --target k8s-cronjob` emits. One image, two roles —
# `ui` (console) and `heartbeat` (an image-provided loop of one-shot
# `areev trigger run`; see docker/heartbeat.sh). Everything else is the CLI
# verbatim. Guide: docs/docker.md
FROM rust:1.90-bookworm AS build
WORKDIR /src
COPY . .
# Cache mounts keep the registry and build artifacts across rebuilds; the
# binary is copied out because the target dir does not survive the RUN.
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/target \
--mount=type=cache,target=/src/areev-sandbox/target \
cargo build --release --locked -p areev --bin areev --features postgres,postgres-tls,tls \
&& cp target/release/areev /usr/local/bin/areev \
&& cargo build --release --locked --manifest-path areev-sandbox/Cargo.toml \
&& cp areev-sandbox/target/release/areev-sandbox /usr/local/bin/areev-sandbox
FROM debian:bookworm-slim
# Nothing to apt-install: TLS is rustls with compiled-in webpki roots, and
# turso's C pieces are statically linked — the runtime needs glibc and /bin/sh
# (for --tool-cmd / --connector-cmd subprocesses), both already here.
COPY --from=build /usr/local/bin/areev /usr/local/bin/areev
COPY --from=build /usr/local/bin/areev-sandbox /usr/local/bin/areev-sandbox
COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY --chmod=755 docker/heartbeat.sh /usr/local/bin/areev-heartbeat
COPY --chmod=755 docker/healthcheck.sh /usr/local/bin/areev-healthcheck
RUN useradd --uid 10001 --create-home areev \
&& mkdir -p /data && chown areev:areev /data
USER areev
WORKDIR /data
VOLUME /data
# Every verb falls back to $AREEV_DB, so `docker run … areev add john …`
# needs no --db flag. Override per container (a path, or a postgres:// DSN).
ENV AREEV_DB=/data/areev.db
EXPOSE 7437
# A container running `ui` is probed at GET /healthz on its own --addr port
# (answered before auth, so no token is needed); every other role has no
# endpoint and reports healthy. bash's /dev/tcp is the client — the slim base
# has no curl/wget and this adds none. See docker/healthcheck.sh.
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD ["areev-healthcheck"]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["--help"]