calathea/Dockerfile

45 lines
934 B
Docker
Raw Normal View History

2025-01-10 12:22:33 +00:00
FROM rust:1.83-alpine3.21 AS builder
ARG DI_VER=1.2.5
WORKDIR /app
RUN apk update && apk add --no-cache build-base
# Build dumb-init
RUN wget -O - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \
cd "dumb-init-${DI_VER}" && \
make SHELL=/bin/sh && \
mv dumb-init .. && \
cd ..
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch --locked
COPY . ./
RUN cargo build --release --frozen
FROM alpine:3.21
2025-01-10 14:29:45 +00:00
COPY --from=builder /app/target/release/calathea /app/calathea
COPY --from=builder /app/dumb-init /app/dumb-init
COPY templates /app/templates
2025-01-10 12:22:33 +00:00
# Create a non-root user & make sure it can write to the data directory
RUN set -x && \
adduser -u 82 -D -S -G www-data www-data && \
mkdir /data && \
chown -R www-data:www-data /data
WORKDIR /data
2025-01-10 14:29:45 +00:00
ENV TEMPLATE_DIR=/app/templates
2025-01-10 12:22:33 +00:00
2025-01-10 14:29:45 +00:00
USER www-data:www-data
2025-01-10 12:22:33 +00:00
2025-01-10 14:29:45 +00:00
ENTRYPOINT [ "/app/dumb-init", "--" ]
CMD [ "/app/calathea" ]