50 lines
1.6 KiB
Docker
50 lines
1.6 KiB
Docker
FROM python:3.14-slim AS browser-libs
|
|
WORKDIR /app
|
|
|
|
ARG BROWSER_LIBS_REFRESH=manual
|
|
COPY scripts/update_browser_libs.py ./scripts/update_browser_libs.py
|
|
COPY scripts/browser-libs.lock.json ./scripts/browser-libs.lock.json
|
|
RUN echo "Browser library download: ${BROWSER_LIBS_REFRESH}" \
|
|
&& python3 ./scripts/update_browser_libs.py --root /app --locked --strict
|
|
|
|
FROM rust:slim-trixie AS builder
|
|
WORKDIR /app
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY migrations ./migrations
|
|
COPY src ./src
|
|
COPY static ./static
|
|
COPY --from=browser-libs /app/static/libs/mermaid ./static/libs/mermaid
|
|
COPY --from=browser-libs /app/static/libs/highlight ./static/libs/highlight
|
|
|
|
RUN cargo build --release
|
|
|
|
FROM debian:13-slim AS runtime
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends ca-certificates curl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& useradd --system --uid 10001 --create-home rustpad \
|
|
&& mkdir -p /app/static /data \
|
|
&& chown -R rustpad:rustpad /app /data
|
|
|
|
WORKDIR /app
|
|
COPY --from=builder /app/target/release/rustpad /usr/local/bin/rustpad
|
|
COPY --from=builder /app/static ./static
|
|
COPY --from=builder /app/migrations ./migrations
|
|
|
|
USER rustpad
|
|
ENV APP_HOST=0.0.0.0 \
|
|
APP_PORT=3000 \
|
|
DATABASE_URL=sqlite:///data/db/rustpad.db?mode=rwc \
|
|
DATABASE_MAX_CONNECTIONS=8 \
|
|
STATIC_DIR=/app/static \
|
|
FILES_DIR=/data/files \
|
|
RUST_LOG=rustpad=info,tower_http=info
|
|
|
|
EXPOSE 3000
|
|
VOLUME ["/data"]
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD curl --fail --silent http://127.0.0.1:3000/health || exit 1
|
|
|
|
ENTRYPOINT ["rustpad"]
|