This commit is contained in:
C菌
2022-04-28 15:50:11 +08:00
parent 94cd2ce218
commit f810b7bc91
4 changed files with 15 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
FROM golang:latest as builder
FROM golang:alpine as builder
# RUN apt install -y git make
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update && apk --no-cache add make git
LABEL anther="cjun"
WORKDIR /tinyurl
COPY . /tinyurl
@@ -9,10 +11,12 @@ RUN make build
FROM alpine:latest AS runner
# 设置alpine 时间为上海时间
RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update && apk --no-cache add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& apk del tzdata
WORKDIR /app
COPY --from=builder /tinyurl/bin/tinyurl /app/tinyurl
COPY --from=builder /tinyurl/dist/ /app/dist/
COPY --from=builder /tinyurl/configs/ /app/configs/
EXPOSE 2830
CMD ["./tinyurl"]