From c011fe69c8030a44f1201e0256c69b08addf98a6 Mon Sep 17 00:00:00 2001 From: Eg <1711788888@qq.com> Date: Wed, 15 Jun 2022 11:43:40 +0800 Subject: [PATCH] :zap: commit ci file --- .drone.yml | 2 +- Dockerfile | 21 ++++++++++++++------- main.go | 1 + 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index 80ad877..2c3e62a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ steps: image: plugins/docker settings: registry: registry.cn-shanghai.aliyuncs.com - repo: registry.cn-shanghai.aliyuncs.com/docker-echo + repo: registry.cn-shanghai.aliyuncs.com/docker-echo/docker username: from_secret: xs765911 password: diff --git a/Dockerfile b/Dockerfile index b061a4a..9540d8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,17 @@ FROM golang:1.18 as builder -WORKDIR /build + + +WORKDIR /builder COPY . . -RUN CGO_ENABLED=0 GOPROXY=https://proxy.golang.com.cn,direct go build -o demo -FROM alpine:3.10 as runner -LABEL description="the image is a demo" +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 WORKDIR /app -COPY --from=builder /build/demo /app/ -EXPOSE 8080 -ENTRYPOINT ["./demo"] \ No newline at end of file +COPY --from=builder /builder/app ./app +CMD ./app \ No newline at end of file diff --git a/main.go b/main.go index 26b154a..79f7c8e 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( //func init() { // client.InitMySQLClient() //} + func main() { app := gin.Default()