clone

a self-hosted sync node for lofi apps: jazz sync over iroh, ticket-gated, with no static ip or cloud needed

feat/browser-cors-sync-tickets
lofi-node / Dockerfile
Dockerfile 2.4K
1# Container image for lofi-node. The build stage compiles the self-contained2# binary on the target platform (the committed prebuilt iroh addons make this3# possible without a Rust toolchain); the runtime stage is a minimal glibc4# base. The addons are gnu builds, so the base must be glibc — do not switch5# to musl/alpine.6#7# linux/amd64 only: jazz-napi publishes no linux-arm64-gnu binary, so an8# arm64 image cannot boot the Jazz server. The guard below fails the build9# rather than producing an image that dies at runtime. arm64 hosts can run10# the amd64 image under emulation (Docker Desktop Rosetta / qemu).11#12# Build: docker build -t lofi-node .13# Run: see compose.yaml and https://lofi.host/node/docs/beyond-the-lan1415FROM denoland/deno:latest AS build16ARG TARGETARCH17RUN if [ "$TARGETARCH" != "amd64" ]; then \18 echo "lofi-node images are linux/amd64 only: jazz-napi ships no" \19 "linux-arm64-gnu binary (upstream gap). Run the amd64 image" \20 "under emulation instead." >&2; \21 exit 1; \22 fi23WORKDIR /src24COPY deno.json deno.lock cli.ts mod.ts ./25COPY src ./src26COPY testing ./testing27COPY native/iroh-js/prebuilt ./native/iroh-js/prebuilt28# Materialize node_modules (jazz-napi's platform package) before compiling;29# deno compile embeds it into the binary's vfs.30RUN deno install31RUN deno task compile:linux-x64 \32 && mv dist/lofi-node-x86_64-unknown-linux-gnu dist/lofi-node3334FROM debian:bookworm-slim35LABEL org.opencontainers.image.source="https://github.com/FelineStateMachine/lofi-node" \36 org.opencontainers.image.description="Self-hostable sync node for lofi apps" \37 org.opencontainers.image.licenses="MIT"38# ca-certificates: TLS to iroh relays and upstream URLs. curl: HEALTHCHECK.39RUN apt-get update \40 && apt-get install -y --no-install-recommends ca-certificates curl \41 && rm -rf /var/lib/apt/lists/* \42 && useradd --uid 1000 --create-home lofi \43 && mkdir /data && chown lofi:lofi /data44COPY --from=build /src/dist/lofi-node /usr/local/bin/lofi-node45USER lofi46VOLUME /data47# The documented container port convention; init with --port 4802 (see docs).48EXPOSE 480249# Probes the gate; unauthenticated in both access modes. Override the port in50# compose if the node was initialized with a different one.51HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \52 CMD curl -fsS http://127.0.0.1:4802/health || exit 153ENTRYPOINT ["lofi-node"]54CMD ["start", "--dir", "/data"]