Build and Push to GHCR / build-and-push (push) Has been cancelled
- Add CONFIG_PATH env support to avoid Docker creating config.json as a directory - Config Save() now auto-creates parent directories - Update docker-compose.yml to mount ./config:/app/config - Update README deployment docs accordingly
31 lines
574 B
Docker
31 lines
574 B
Docker
# 构建阶段
|
|
FROM golang:1.23-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
COPY go.mod go.sum* ./
|
|
RUN go mod download 2>/dev/null || true
|
|
|
|
COPY . .
|
|
RUN go build -ldflags="-s -w" -o mirror-proxy ./cmd/main.go
|
|
|
|
# 运行阶段
|
|
FROM alpine:latest
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
WORKDIR /app
|
|
|
|
# 创建必要目录
|
|
RUN mkdir -p web/static cache config
|
|
|
|
# 复制编译后的二进制文件和静态资源
|
|
COPY --from=builder /app/mirror-proxy .
|
|
COPY --from=builder /app/web/static ./web/static
|
|
|
|
# 暴露默认端口
|
|
EXPOSE 8080
|
|
|
|
VOLUME ["/app/cache"]
|
|
|
|
ENTRYPOINT ["./mirror-proxy"]
|