Browse Source

tmr: cicd

Yi 1 year ago
parent
commit
eafa5252d1
2 changed files with 21 additions and 14 deletions
  1. 2 2
      .drone.yml
  2. 19 12
      Dockerfile

+ 2 - 2
.drone.yml

@@ -4,7 +4,7 @@ name: kpt-tmr
 
 steps:
   - name: build
-    image: plugins/docker
+    image: plugins/docker:20.14.2
     volumes:
       - name: hosts
         path: /etc/hosts
@@ -13,7 +13,7 @@ steps:
       - name: docker-sock
         path: /var/run/docker.sock
     settings:
-      dockerfile: /drone/src/Dockerfile
+      # dockerfile: /drone/src/Dockerfile
       username:
         from_secret: aliyun_name
       password:

+ 19 - 12
Dockerfile

@@ -1,19 +1,26 @@
-FROM golang:1.17-alpine3.16 as builder
+FROM golang:1.17-alpine as build
 
+WORKDIR /app/kpt-tmr
+
+COPY . .
+
+RUN mkdir -p ./bin
+
+RUN go env -w GO111MODULE=on && \
+    go env -w GOPROXY=https://goproxy.cn,direct && \
+    go env -w CGO_ENABLED=0 && \
+    go env -w GOARCH=amd64 && \
+    go env -w GOOS=linux && \
+    go build -o ./bin/kptTmr -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-tmr/pod.appVersion=tmr" main.go
+
+
+FROM alpine:latest
 LABEL name="kpt-tmr" \
 description="pt service" \
 owner="yiping.xu"
 
-WORKDIR /bin
-
-RUN rm -rf bin && \
-    mkdir -p bin && \
-    GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o bin/kptTmr -ldflags "-X kpt.kptyun.cn:3000/kpt-tmr/pod.app" main.go
-
-ADD ./bin/kptTmr /bin/kptTmr
-COPY config/ /bin/config/
+WORKDIR /app/kpt-tmr
 
-EXPOSE 8081
-VOLUME /bin/logger
 
-CMD ["/bin/kptTmr"]
+COPY --from=0 /app/kpt-tmr/config/*.ini /app/kpt-tmr/bin/config/
+COPY --from=0  /app/kpt-tmr/bin/kptTmr /app/kpt-tmr/bin/kptTmr