File size: 1,015 Bytes
80ffd2e 3f45fc8 80ffd2e 644c352 80ffd2e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # Build stage
FROM golang:1.23-alpine AS builder
WORKDIR /app
# 配置 Go 代理加速下载(使用国内镜像)
ENV GOPROXY=https://goproxy.cn,https://goproxy.io,direct
ENV GOSUMDB=off
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build binary
RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server
# Run stage
FROM python:3.9-slim
WORKDIR /app
# Install any system dependencies if needed
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy binary from builder
COPY --from=builder /app/server .
# Copy Python startup script
COPY app.py .
# Copy web static files
COPY --from=builder /app/web ./web
# Create logs directory
RUN mkdir -p /app/logs
# Hugging Face Spaces uses port 7860
EXPOSE 7860
# Set environment variable
ENV PORT=7860
# Run server via Python script
CMD ["python", "app.py"] |