build: digest-pinned, non-root image with healthcheck; hardened compose with full env passthrough
NOT yet built or run: the Docker daemon's storage was failing at commit time. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
45
Dockerfile
45
Dockerfile
@@ -1,28 +1,55 @@
|
||||
FROM node:22-bookworm AS web
|
||||
# syntax=docker/dockerfile:1
|
||||
# Base images are pinned by multi-arch index digest. To update, run
|
||||
# `docker buildx imagetools inspect <image:tag>` and replace the digest.
|
||||
FROM node:22-bookworm@sha256:e13726ca604184d7a91fcacab1fc09eefd642dc28e79ac34e85540dd93b78cfb AS web
|
||||
WORKDIR /build
|
||||
COPY web/package.json web/package-lock.json* ./
|
||||
RUN npm ci
|
||||
COPY web/ ./
|
||||
RUN npm run build
|
||||
|
||||
FROM rust:1.89-bookworm AS rust
|
||||
FROM rust:1.89-bookworm@sha256:948f9b08a66e7fe01b03a98ef1c7568292e07ec2e4fe90d88c07bb14563c84ff AS rust
|
||||
WORKDIR /build
|
||||
COPY Cargo.toml Cargo.lock* ./
|
||||
COPY crates ./crates
|
||||
COPY --from=web /build/dist ./web/dist
|
||||
RUN cargo build --release -p tessera-hub
|
||||
RUN cargo build --release --locked -p tessera-hub -p tessera-cli
|
||||
|
||||
FROM restic/restic:0.19.1 AS restic
|
||||
FROM mysql:8.4 AS mysql-client
|
||||
FROM restic/restic:0.19.1@sha256:136600b6ff6843d61d355f7f71f460a166429f35de6fd11b568fece3c9a4d510 AS restic
|
||||
FROM mysql:8.4@sha256:a81d043930e51745522bd5c430961cf8286f0a23f0a9a2a6e0108f7ea71b0902 AS mysql-client
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates postgresql-client libstdc++6 && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=rust /build/target/release/tessera-hub /usr/local/bin/
|
||||
FROM debian:bookworm-slim@sha256:734a72b3d6142a71993b4bc580ca01d8ca687f77a2c422d96a961d3376b179bc
|
||||
# Bookworm ships pg_dump 15, which refuses to dump a newer server. Install a
|
||||
# current client from the PostgreSQL project's apt repository (PGDG) instead.
|
||||
# pg_dump 17 dumps servers 9.2 through 17.
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates curl gnupg libstdc++6 \
|
||||
&& install -d /usr/share/keyrings \
|
||||
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/pgdg.gpg \
|
||||
&& echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends postgresql-client-17 \
|
||||
&& apt-get purge -y --auto-remove curl gnupg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=rust /build/target/release/tessera-hub /build/target/release/tessera /usr/local/bin/
|
||||
COPY --from=restic /usr/bin/restic /usr/local/bin/restic
|
||||
COPY --from=mysql-client /usr/bin/mysqldump /usr/local/bin/mysqldump
|
||||
RUN restic version && mysqldump --version
|
||||
COPY --chmod=0755 <<'EOF2' /usr/local/bin/tessera-healthcheck
|
||||
#!/bin/bash
|
||||
# Minimal HTTP GET /health using bash's /dev/tcp, so the slim image needs no curl.
|
||||
port="${TESSERA_LISTEN##*:}"
|
||||
exec 3<>"/dev/tcp/127.0.0.1/${port:-8787}" || exit 1
|
||||
printf 'GET /health HTTP/1.0\r\nHost: localhost\r\n\r\n' >&3
|
||||
IFS= read -r status <&3
|
||||
[[ "$status" == HTTP/*" 200 "* ]]
|
||||
EOF2
|
||||
RUN restic version && mysqldump --version && pg_dump --version && tessera --help >/dev/null \
|
||||
&& useradd --system --uid 10001 --user-group --home-dir /home/tessera --create-home tessera \
|
||||
&& install -d -o tessera -g tessera /data
|
||||
ENV TESSERA_LISTEN=0.0.0.0:8787
|
||||
ENV TESSERA_DATA_DIR=/data
|
||||
EXPOSE 8787
|
||||
VOLUME ["/data"]
|
||||
USER tessera
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 CMD ["/usr/local/bin/tessera-healthcheck"]
|
||||
ENTRYPOINT ["tessera-hub"]
|
||||
|
||||
Reference in New Issue
Block a user