first commit
This commit is contained in:
46
backend_rust/Dockerfile
Normal file
46
backend_rust/Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
# Build stage
|
||||
FROM rust:1.84-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache musl-dev pkgconfig openssl-dev
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy manifests
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY migration/Cargo.toml ./migration/
|
||||
|
||||
# Create dummy files to build dependencies
|
||||
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
||||
RUN mkdir -p migration/src && echo "fn main() {}" > migration/src/main.rs && echo "" > migration/src/lib.rs
|
||||
|
||||
# Build dependencies only
|
||||
RUN cargo build --release
|
||||
|
||||
# Remove dummy files
|
||||
RUN rm -rf src migration/src
|
||||
|
||||
# Copy actual source code
|
||||
COPY src ./src
|
||||
COPY migration/src ./migration/src
|
||||
|
||||
# Build the actual application
|
||||
RUN touch src/main.rs migration/src/main.rs migration/src/lib.rs
|
||||
RUN cargo build --release
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:3.21
|
||||
|
||||
RUN apk add --no-cache ca-certificates libgcc
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the binary from builder
|
||||
COPY --from=builder /app/target/release/backend_rust /app/backend_rust
|
||||
COPY --from=builder /app/target/release/migration /app/migration
|
||||
|
||||
# Create uploads directory
|
||||
RUN mkdir -p /app/uploads/avatars
|
||||
|
||||
EXPOSE 4000
|
||||
|
||||
CMD ["/app/backend_rust"]
|
||||
Reference in New Issue
Block a user