Files
mengpost/mengpost-backend/Dockerfile

25 lines
688 B
Docker
Raw Permalink 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.
# 多阶段构建,纯 GoCGO_ENABLED=0+ modernc.org/sqlite适合 Alpine运行。
# 对外映射建议:主机 28088 ->容器 8088见 docker-compose.yml
FROM golang:alpine AS build
WORKDIR /src
RUN apk add --no-cache git
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ENV CGO_ENABLED=0
RUN go build -trimpath -ldflags="-s -w" -o /out/mengpost-api .
FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata
ENV TZ=Asia/Shanghai
WORKDIR /app
RUN mkdir -p /app/data
COPY --from=build /out/mengpost-api /app/mengpost-api
ENV GIN_MODE=release
ENV MP_PORT=8088
ENV MP_DB=/app/data/mengpost.db
EXPOSE 8088
ENTRYPOINT ["/app/mengpost-api"]