feat: Add Dockerfile and Docker Compose configuration for containerized deployment and update README with instructions.

This commit is contained in:
2026-03-03 19:19:47 +00:00
parent bfcf45343f
commit b93d4548d4
3 changed files with 91 additions and 0 deletions

46
Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
# Build Stage
FROM rust:1.85-bookworm AS builder
WORKDIR /app
# Cache dependencies
# We create a dummy project to build only dependencies
RUN cargo new --bin blog_cms
COPY Cargo.toml Cargo.lock ./
RUN cargo build --release
RUN rm src/*.rs
# Copy real source
COPY src ./src
COPY templates ./templates
# The templates are needed during compilation by askama
# Rebuild the real source
RUN touch src/main.rs && cargo build --release
# Final Stage
FROM debian:bookworm-slim
WORKDIR /app
# Install runtime dependencies (like SSL certificates and sqlite)
RUN apt-get update && apt-get install -y \
ca-certificates \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy the binary from the builder
COPY --from=builder /app/target/release/blog_cms .
# Create directory for attachments and database
RUN mkdir -p attachments
# Default environment variables
ENV PORT=3000
ENV DATABASE_URL=sqlite:///app/data.db
# Expose the application port
EXPOSE 3000
# Start the application
CMD ["./blog_cms"]