mirror of
https://github.com/storytold/figcraft.git
synced 2026-12-02 15:01:23 -05:00
92e3622177
figcraft-server healthcheck asks the server on the listen address for /healthz (exit 0 on 200, 1 otherwise), and the distroless image declares it as its HEALTHCHECK. packaging/server/docker-compose.yml builds the image and takes its FIGCRAFT_SERVER_* settings from a .env file beside it, with trusted_proxy defaulting to Docker's address range and the port on loopback. docs/server.md covers the subcommand, Compose, and running behind a platform proxy that ends TLS. Part of #2044.
30 lines
1.4 KiB
Docker
30 lines
1.4 KiB
Docker
# figcraft-server in a container; setup in docs/server.md ("Deploy on a Linux server"). Build from
|
|
# the repository root:
|
|
#
|
|
# docker build -f packaging/server/Dockerfile -t figcraft-server .
|
|
#
|
|
# The image runs as an unprivileged user, keeps its files in the /data volume and reads
|
|
# /etc/figcraft-server/server.toml (listen on 0.0.0.0:47900, data in /data; mount your own to set
|
|
# public_url, or set it as FIGCRAFT_SERVER_PUBLIC_URL). `docker stop` sends SIGTERM: the server
|
|
# saves open files and stops gracefully. docker-compose.yml beside this file runs it with Compose.
|
|
|
|
FROM rust:1-bookworm AS build
|
|
WORKDIR /src
|
|
COPY . .
|
|
RUN cargo build --release --locked -p figcraft-server \
|
|
&& mkdir -p /out/data \
|
|
&& printf 'listen = "0.0.0.0:47900"\ndata = "/data"\n' > /out/server.toml
|
|
|
|
# glibc and libgcc only, no shell; "nonroot" is uid 65532.
|
|
FROM gcr.io/distroless/cc-debian12:nonroot
|
|
COPY --from=build /src/target/release/figcraft-server /usr/local/bin/figcraft-server
|
|
COPY --from=build /out/server.toml /etc/figcraft-server/server.toml
|
|
COPY --from=build --chown=nonroot:nonroot /out/data /data
|
|
USER nonroot
|
|
VOLUME /data
|
|
EXPOSE 47900
|
|
STOPSIGNAL SIGTERM
|
|
# No curl in the image: the server asks itself for /healthz.
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s CMD ["/usr/local/bin/figcraft-server", "--config", "/etc/figcraft-server/server.toml", "healthcheck"]
|
|
ENTRYPOINT ["/usr/local/bin/figcraft-server", "--config", "/etc/figcraft-server/server.toml"]
|