FROM golang:1.18-alpine

ARG app_env=production
ARG commit_hash
ARG git_access_token
LABEL maintainer="shenjing.zhao@pingcap.com"
LABEL commit_hash="${commit_hash}"
LABEL app="pingcat"
LABEL component="apiserver"
ENV GIN_MODE="release"
ENV GOPRIVATE="github.com/pingcap-inc/pchub"
WORKDIR /apps
COPY go.mod ./
COPY go.sum ./
RUN apk update
RUN apk add git
RUN git config --global url.https://${git_access_token}@github.com/.insteadOf https://github.com/
RUN go mod tidy

COPY . ./

RUN go build -o . /apps/cmd/pingcat-apiserver

VOLUME [ "/apps/config", "/apps/logs" ]
EXPOSE 8867
ENTRYPOINT /apps/pingcat-apiserver -c=/apps/config/config-prod.yaml
