Files
2026-05-16 19:19:39 +08:00

24 lines
733 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.
# 与 go.mod 中 go 版本一致modernc.org/sqlite 等依赖会抬高 toolchain 要求)
FROM golang:1.25-alpine AS builder
WORKDIR /app
RUN apk add --no-cache ca-certificates
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
ARG TARGETOS=linux
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /mengyaconnect-backend .
FROM alpine:3.19
WORKDIR /app
RUN apk add --no-cache ca-certificates && \
adduser -D -H appuser
COPY --from=builder /mengyaconnect-backend /app/mengyaconnect-backend
ENV DATA_DIR=/app/data
ENV PORT=8080
RUN chmod +x /app/mengyaconnect-backend && \
mkdir -p "$DATA_DIR" && chown -R appuser:appuser /app
USER appuser
EXPOSE 8080
CMD ["/app/mengyaconnect-backend"]