RTIX / Dockerfile
github-actions
deploy: clean backend production release
d8ffec9
# Stage 1: Build dependencies & application
FROM rust:1.94-slim-bookworm AS builder
USER root
# Install system dependencies required for compiling Rust libraries (like openssl, cmake, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends pkg-config libssl-dev cmake g++ ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy dependency manifests first
COPY Cargo.toml Cargo.lock ./
# Create dummy source files so we can cache dependency compilation
RUN mkdir -p src \
&& echo "" > src/lib.rs \
&& echo "fn main() {}" > src/main.rs
# Build dependencies in release mode (caching layer)
RUN cargo build --release
# Copy the real source code
COPY . .
# Touch source files to ensure cargo compiles them with the real contents
RUN touch src/lib.rs src/main.rs
# Set SQLx offline compilation mode so we don't need a database connection at compile time
ENV SQLX_OFFLINE=true
# Recompile the actual application
RUN cargo build --release --bin rtix
# Stage 2: Minimal Runtime
FROM debian:bookworm-slim AS runtime
# Install runtime SSL dependencies and curl for health check
RUN apt-get update \
&& apt-get install -y --no-install-recommends libssl3 ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the compiled binary from builder
COPY --from=builder /app/target/release/rtix /usr/local/bin/rtix
# Hugging Face Spaces requires port 7860
ENV PORT=7860
ENV SERVER_PORT=7860
# OAuth defaults (override with HF Secrets in Space settings)
ENV OAUTH_REDIRECT_BASE=https://gowtham851-rtix.hf.space
ENV FRONTEND_URL=https://rtix.vercel.app
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD curl -fsS "http://127.0.0.1:7860/health" > /dev/null || exit 1
CMD ["rtix"]