Files
mengyamonitor/mengyamonitor-backend-server/Dockerfile
2026-05-16 19:03:34 +08:00

22 lines
685 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 中心服务HTTP/WebSocket + gRPC纯 Go / modernc SQLiteCGO_ENABLED=0
# 镜像内进程为明文 HTTPHTTPS 请在宿主机 Nginx 等反代层配置,内网直连本端口即可。
FROM golang:1.22-alpine AS build
WORKDIR /src
RUN apk add --no-cache git
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /central .
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
# 与 config 默认一致; compose 中可覆盖
ENV HOST=0.0.0.0
ENV PORT=9393
ENV GRPC_PORT=9394
ENV DB_PATH=/app/data/servers.db
COPY --from=build /central /app/central
EXPOSE 9393 9394
ENTRYPOINT ["/app/central"]