- Add .env.example file for environment variable setup - Add .gitignore to manage sensitive files and directories - Add Dockerfile.prod for production-ready Docker image - Add PRODUCTION_CHECKLIST.md for pre/post deployment steps - Add PRODUCTION_DEPLOYMENT.md for deployment instructions - Add STRIPE_SETUP.md for Stripe payment configuration - Add config/default.toml for default configuration settings - Add config/local.toml.example for local configuration template
70 lines
1.4 KiB
Docker
70 lines
1.4 KiB
Docker
# Multi-stage build for production
|
|
FROM rust:1.75-slim as builder
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
pkg-config \
|
|
libssl-dev \
|
|
libpq-dev \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create app directory
|
|
WORKDIR /app
|
|
|
|
# Copy dependency files
|
|
COPY Cargo.toml Cargo.lock ./
|
|
|
|
# Create a dummy main.rs to build dependencies
|
|
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
|
|
|
# Build dependencies (this layer will be cached)
|
|
RUN cargo build --release && rm -rf src
|
|
|
|
# Copy source code
|
|
COPY src ./src
|
|
COPY tests ./tests
|
|
|
|
# Build the application
|
|
RUN cargo build --release
|
|
|
|
# Runtime stage
|
|
FROM debian:bookworm-slim
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
ca-certificates \
|
|
libssl3 \
|
|
libpq5 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create app user
|
|
RUN useradd -m -u 1001 appuser
|
|
|
|
# Create app directory
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder stage
|
|
COPY --from=builder /app/target/release/actix_mvc_app /app/actix_mvc_app
|
|
|
|
# Copy static files and templates
|
|
COPY src/views ./src/views
|
|
COPY static ./static
|
|
|
|
# Create data and logs directories
|
|
RUN mkdir -p data logs && chown -R appuser:appuser /app
|
|
|
|
# Switch to app user
|
|
USER appuser
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD curl -f http://localhost:8080/health || exit 1
|
|
|
|
# Run the application
|
|
CMD ["./actix_mvc_app"]
|