# Multi-stage build: compile frontend assets, build the Rust binaries, then
# assemble a minimal Debian runtime. Kept Kaniko-clean: no BuildKit cache
# mounts and no `# syntax=` directive.
# ---------------------------------------------------------------------------
# Stage 1 — assets: compile Tailwind CSS, bundle JS, stage FontAwesome webfonts.
# ---------------------------------------------------------------------------
FROM node:20-alpine AS assets
WORKDIR /app
COPY assets/package.json assets/package-lock.json ./assets/
RUN cd assets && npm ci --no-audit --no-fund
COPY assets/tailwind.config.js ./assets/
COPY assets/f ./assets/f
COPY templates ./templates
RUN cd assets \
&& ./node_modules/.bin/tailwindcss -c tailwind.config.js -i f/css/style.css -o f/css/app.css \
&& ./node_modules/.bin/esbuild f/js/src.js --bundle --minify --loader:.frag=text --outfile=f/js/app.js \
&& mkdir -p f/webfonts \
&& cp node_modules/@fortawesome/fontawesome-free/webfonts/*.woff2 f/webfonts/ \
&& cp node_modules/@fortawesome/fontawesome-free/webfonts/*.ttf f/webfonts/
# ---------------------------------------------------------------------------
# Stage 2 — rust-builder: build the web + CLI binaries in release mode.
# ---------------------------------------------------------------------------
FROM rust:1.92-bookworm AS rust-builder
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends pkg-config libssl-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY Cargo.toml Cargo.lock build.rs ./
COPY migration/Cargo.toml migration/
COPY migration/src migration/src
# Vendored mail-prism client (workspace member) and the mail templates that
# src/mailer.rs compiles in with include_str!.
COPY crates crates
COPY mail_prism mail_prism
COPY src src
COPY templates templates
# Tailwind output from stage 1 — build.rs embeds templates and ServeDir needs assets/f.
COPY --from=assets /app/assets/f ./assets/f
RUN cargo build --release --locked --bin recourse --bin manage \
&& mkdir -p /out \
&& cp target/release/recourse /out/ \
&& cp target/release/manage /out/ \
&& rm -rf target
# ---------------------------------------------------------------------------
# Stage 3 — runtime: minimal Debian slim with binaries + assets + templates.
# ---------------------------------------------------------------------------
FROM debian:bookworm-slim AS runtime
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates libssl3 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --system --gid 10001 app \
&& useradd --system --uid 10001 --gid app --home /app --shell /usr/sbin/nologin app \
&& mkdir -p /app \
&& chown -R app:app /app
WORKDIR /app
COPY --from=rust-builder /out/recourse /usr/local/bin/recourse
COPY --from=rust-builder /out/manage /usr/local/bin/manage
COPY --from=assets /app/assets/f /app/assets/f
COPY --chown=app:app templates /app/templates
USER app
ENV BIND_ADDRESS=0.0.0.0:3000 \
AUTO_MIGRATE=true \
REGISTRATION_ENABLED=false
EXPOSE 3000
# `docker run … recourse` → web service (default)
# `docker run … manage invite create --days 7` → admin CLI (users, invites)
CMD ["recourse"]
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
3.2 KiB · text
History
263b40b