fix: Simplify Dockerfile to use sqlx offline mode
All checks were successful
Test Asgard Runner / test (push) Successful in 2s
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user