fix: Simplify Dockerfile to use sqlx offline mode
All checks were successful
Test Asgard Runner / test (push) Successful in 2s

- Remove complex build caching
- Set SQLX_OFFLINE=true to skip compile-time query verification
- Queries still validated at runtime
- Eliminates need for DATABASE_URL during Docker build
This commit is contained in:
Vantz Stockwell
2026-02-15 17:28:56 -05:00
parent 109476d5e3
commit d7dddca106

View File

@@ -6,16 +6,15 @@ RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/li
WORKDIR /build
# Cache dependencies — copy manifests first
COPY Cargo.toml ./
COPY Cargo.lock* ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release 2>/dev/null || true
# Now copy actual source and build
# Copy everything
COPY Cargo.toml Cargo.lock* ./
COPY src/ src/
COPY migrations/ migrations/
RUN touch src/main.rs && cargo build --release
# Build with sqlx offline mode to skip compile-time query verification
# Runtime validation still occurs - just no compile-time type checking
ENV SQLX_OFFLINE=true
RUN cargo build --release
# Stage 2: Runtime image
FROM debian:bookworm-slim
@@ -25,7 +24,7 @@ RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/
WORKDIR /app
COPY --from=builder /build/target/release/corrosion-api .
COPY migrations/ migrations/
COPY --from=builder /build/migrations/ migrations/
ENV RUST_LOG=corrosion_api=info,tower_http=info