Fix Docker configuration for deployment
- Update backend Dockerfile to use Rust 1.85 (edition 2024 support) - Add Aliyun mirrors for Alpine packages - Add rsproxy.cn mirror for cargo crates - Enable static OpenSSL linking - Fix frontend Dockerfile to use NEXT_PUBLIC_API_BASE - Add mkdir -p public to ensure public dir exists - Update docker-compose files to use correct env var names - Add docker-compose.deploy.yml for production deployment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
# Build stage
|
||||
FROM rust:1.84-alpine AS builder
|
||||
FROM rust:1.85-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache musl-dev pkgconfig openssl-dev
|
||||
# Use Aliyun mirrors for faster package downloads in China
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static
|
||||
|
||||
# Configure cargo to use rsproxy.cn mirror for crates
|
||||
RUN mkdir -p /usr/local/cargo && printf '[source.crates-io]\nreplace-with = "rsproxy-sparse"\n\n[source.rsproxy-sparse]\nregistry = "sparse+https://rsproxy.cn/index/"\n\n[net]\ngit-fetch-with-cli = true\n' > /usr/local/cargo/config.toml
|
||||
|
||||
# Static OpenSSL linking
|
||||
ENV OPENSSL_STATIC=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -30,13 +39,15 @@ RUN cargo build --release
|
||||
# Runtime stage
|
||||
FROM alpine:3.21
|
||||
|
||||
# Use Aliyun mirrors
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user