drone-test/Dockerfile

17 lines
459 B
Docker
Raw Normal View History

2022-06-15 10:58:05 +08:00
FROM golang:1.18 as builder
2022-06-15 11:43:40 +08:00
WORKDIR /builder
2022-06-15 10:58:05 +08:00
COPY . .
2022-06-15 11:43:40 +08:00
RUN go mod download && go build -o app && upx -9 app
RUN ls -lh && chmod +x ./app
# 指定创建的基础镜像
FROM alpine as runner
# 替换阿里云的源
RUN echo "http://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories
RUN echo "http://mirrors.aliyun.com/alpine/latest-stable/community/" >> /etc/apk/repositories
2022-06-15 10:58:05 +08:00
WORKDIR /app
2022-06-15 11:43:40 +08:00
COPY --from=builder /builder/app ./app
CMD ./app