Files
inbuxa-server/Dockerfile.relay
jcoffey-dev 9bf8974d23
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 11m26s
Secrets from files: INBUXA_<name>_FILE (K-S2)
INBUXA_RECOVERY_ADMIN and INBUXA_WEBMAIL_CLIENT_SECRET can come instead
from a file that INBUXA_RECOVERY_ADMIN_FILE or
INBUXA_WEBMAIL_CLIENT_SECRET_FILE names, such as a mounted Kubernetes or
Docker secret, so a secret never has to sit in the environment, where
anything that can read the process's environment or the pod spec sees
it. The relay's INBUXA_RELAY_JOIN_TOKEN takes _FILE the same way.

The file's trailing newline is dropped. Both forms set, or a file that
can't be read or is empty, stops the server as it starts (boot checks
every one), naming the variable and the path, never the secret.

The rule lives in types::branding::secret_env_var, its core a pure
function the unit tests drive; SECRET_ENV_VARS lists the variables it
covers.
2026-11-18 15:09:30 -07:00

42 lines
1.9 KiB
Docker

# inbuxa Relay's image (relay spec, RL-31): the inbuxa-relay binary and
# nothing of the server. It is a static musl build, built natively for the
# platform asked for (each architecture has its own runner), so the binary
# taken out of this image for a Release runs on any Linux of that
# architecture.
#
# docker buildx build -f Dockerfile.relay --platform linux/amd64 .
#
# The image runs as an unprivileged user (2001), may bind ports 25 and 443 and
# nothing more, and keeps its state in /var/lib/inbuxa-relay. It sets
# INBUXA_RELAY_CONTAINER, so the relay reports selfUpgrade: false and an
# upgrade is a new image (RL-29). On its first run it joins with
# INBUXA_RELAY_JOIN_TOKEN, or the token in the file
# INBUXA_RELAY_JOIN_TOKEN_FILE names (a mounted secret).
#
# Docker Hub images, pulled through Google's mirror, as in Dockerfile.
FROM mirror.gcr.io/library/rust:1-alpine3.22 AS builder
RUN apk add --no-cache musl-dev build-base cmake perl libcap ca-certificates
WORKDIR /build
COPY . .
RUN cargo build --release --locked -p inbuxa-relay && \
install -m 0755 target/release/inbuxa-relay /inbuxa-relay && \
# Static, or it won't run on a host without musl
! ldd /inbuxa-relay 2>/dev/null | grep -q '=>' && \
# Set here: the copy below keeps it
setcap 'cap_net_bind_service=+ep' /inbuxa-relay && \
mkdir -m 0700 /state
# The binary and the CA roots, nothing else (RL-30): no shell, no package
# manager. The user is a number, as there is no /etc/passwd.
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /inbuxa-relay /usr/local/bin/inbuxa-relay
COPY --from=builder --chown=2001:2001 /state /var/lib/inbuxa-relay
USER 2001:2001
WORKDIR /var/lib/inbuxa-relay
VOLUME ["/var/lib/inbuxa-relay"]
ENV INBUXA_RELAY_CONTAINER=1
EXPOSE 25 443
ENTRYPOINT ["/usr/local/bin/inbuxa-relay"]
CMD ["run", "--state", "/var/lib/inbuxa-relay"]