FROM registry.cn-hangzhou.aliyuncs.com/jcce-images/golang:1.22.4-alpine3.20 AS builder

WORKDIR /app
COPY . .

ENV GO111MODULE=on GOPROXY=https://goproxy.cn,direct
RUN go mod download

RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o pcm-core-api


FROM registry.cn-hangzhou.aliyuncs.com/jcce-images/alpine:3.20
WORKDIR /app

#修改alpine源为上海交通大学
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/g' /etc/apk/repositories && \
  apk add --no-cache ca-certificates && update-ca-certificates && \
  apk add --update tzdata && \
  rm -rf /var/cache/apk/*

COPY --from=builder /app/pcm-core-api .
COPY etc/pcm.yaml .

ENV TZ=Asia/Shanghai

EXPOSE 8999

ENTRYPOINT ./pcm-core-api --f pcm.yaml