FROM golang:1.21-alpine AS builder ARG APK_MIRROR=https://mirrors.aliyun.com/alpine ARG GOPROXY=https://goproxy.cn,direct RUN set -eux; \ printf '%s\n' \ "${APK_MIRROR}/v3.20/main" \ "${APK_MIRROR}/v3.20/community" > /etc/apk/repositories; \ apk add --no-cache ca-certificates tzdata git WORKDIR /src COPY go.mod go.sum ./ ENV GOPROXY=${GOPROXY} RUN go mod download COPY . . RUN set -eux; \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ go build -trimpath -ldflags="-s -w" -o /out/qr-scanner . FROM alpine:3.20 ARG APK_MIRROR=https://mirrors.aliyun.com/alpine RUN set -eux; \ printf '%s\n' \ "${APK_MIRROR}/v3.20/main" \ "${APK_MIRROR}/v3.20/community" > /etc/apk/repositories; \ apk add --no-cache ca-certificates tzdata; \ addgroup -S app && adduser -S -G app app WORKDIR /app COPY --from=builder /out/qr-scanner /app/qr-scanner COPY --from=builder /src/static /app/static USER app EXPOSE 8080 ENTRYPOINT ["/app/qr-scanner"]