This commit is contained in:
mangomqy
2025-11-13 02:54:06 +00:00
commit c5e51ed069
254 changed files with 54901 additions and 0 deletions

41
backend/Dockerfile Normal file
View File

@ -0,0 +1,41 @@
# ==================================================
# OCDP Backend - Dockerfile
# 构建 backend 服务(连接 PostgreSQL
# ==================================================
FROM golang:1.24-alpine AS builder
RUN apk add --no-cache git make
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-w -s" -o ocdp-backend cmd/api/main.go
# ==================================================
# Runtime
# ==================================================
FROM alpine:latest
RUN apk --no-cache add ca-certificates curl
RUN addgroup -g 1000 ocdp && \
adduser -D -u 1000 -G ocdp ocdp
WORKDIR /app
COPY --from=builder /build/ocdp-backend .
COPY --from=builder /build/config ./config
RUN chown -R ocdp:ocdp /app
USER ocdp
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
CMD ["./ocdp-backend"]