Initial commit: VRBattles API

This commit is contained in:
root
2026-01-20 05:41:25 +00:00
commit c26a1820d5
42 changed files with 6187 additions and 0 deletions

60
Dockerfile Normal file
View File

@@ -0,0 +1,60 @@
# Build stage
FROM rust:latest AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy manifests
COPY Cargo.toml Cargo.lock* ./
# Create dummy main.rs to cache dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Build dependencies (this will be cached)
RUN cargo build --release && rm -rf src
# Copy source code
COPY src ./src
COPY migrations ./migrations
# Build the actual application
RUN touch src/main.rs && cargo build --release
# Runtime stage
FROM debian:trixie-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy the binary
COPY --from=builder /app/target/release/vrbattles-api /app/vrbattles-api
# Copy migrations
COPY --from=builder /app/migrations /app/migrations
# Create non-root user
RUN useradd -r -s /bin/false vrbattles && \
chown -R vrbattles:vrbattles /app
USER vrbattles
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Run the binary
CMD ["./vrbattles-api"]