37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
# Build the Go Binary
|
|
FROM golang:1.17 as build_sales-api
|
|
ENV CGO_ENABLE 0
|
|
ENV GOPROXY https://goproxy.io,direct
|
|
ARG BUILD_REF
|
|
|
|
# Copy the source code into the container
|
|
COPY . /service
|
|
|
|
# Build the service binary
|
|
WORKDIR /service/app/services/sales-api
|
|
RUN go build -ldflags "-X main.build=${BUILD_REF}"
|
|
|
|
|
|
# todo 设置时区
|
|
# Run the Go Binary in Alpine
|
|
FROM alpine:3.15
|
|
ARG BUILD_DATE
|
|
ARG BUILD_REF
|
|
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
|
|
RUN echo 'http://mirrors.ustc.edu.cn/alpine/v3.15/main' > /etc/apk/repositories && \
|
|
echo 'http://mirrors.ustc.edu.cn/alpine/v3.15/community' >>/etc/apk/repositories && \
|
|
apk update && apk add -U tzdata && \
|
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
echo "Asia/Shanghai" > /etc/timezone && \
|
|
apk del tzdata
|
|
COPY --from=build_sales-api /service/app/services/sales-api/sales-api /service/sales-api
|
|
WORKDIR /service
|
|
CMD ["./sales-api"]
|
|
|
|
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
|
|
org.opencontainers.image.title="sales-api" \
|
|
org.opencontainers.image.author="Xiaoweihong" \
|
|
org.opencontainers.image.source="https://git.hongxiaowei.com/xiaowei/service/app/sales-api" \
|
|
org.opencontainers.image.revision="${BUILD_REF}" \
|
|
org.opencontainers.image.vendor="Xiao Wei"
|