feat(docker): Added docker setup

This commit is contained in:
2026-06-25 10:22:40 +05:30
parent 51373fa6ec
commit e264f9f238
3 changed files with 55 additions and 4 deletions

45
Dockerfile Normal file
View File

@@ -0,0 +1,45 @@
# Build stage
FROM rust:1.80-slim as builder
WORKDIR /usr/src/app
# Install dependencies required for building
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
# Copy the manifests
COPY Cargo.toml Cargo.lock ./
# Create a dummy main.rs to build dependencies and cache them
RUN mkdir src && \
echo "fn main() {}" > src/main.rs && \
cargo build --release && \
rm -rf src
# Copy the actual source code and migrations
COPY src ./src
COPY migrations ./migrations
# Touch main.rs to ensure cargo rebuilds it
RUN touch src/main.rs && cargo build --release
# Runtime stage
FROM debian:bookworm-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y ca-certificates sqlite3 && rm -rf /var/lib/apt/lists/*
# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/app/target/release/bootstrap-auth-server /usr/local/bin/bootstrap-auth-server
# Set environment variables
ENV SERVER_PORT=3000
ENV DATABASE_URL="sqlite://data.db?mode=rwc"
ENV RUST_LOG="bootstrap_auth_server=debug,info"
# Expose the port
EXPOSE 3000
# Run the binary
ENTRYPOINT ["bootstrap-auth-server"]