Browse Source

project: add cicd 6

Yi 1 year ago
parent
commit
e3841430a9
2 changed files with 19 additions and 18 deletions
  1. 9 9
      .drone.yml
  2. 10 9
      Dockerfile

+ 9 - 9
.drone.yml

@@ -2,17 +2,17 @@ kind: pipeline
 type: docker
 type: docker
 name: kptTmrGroup
 name: kptTmrGroup
 
 
-clone:
-  depth: 1
-  disable: true
+#clone:
+#  depth: 1
+#  disable: true
 
 
 steps:
 steps:
-  - name: clone
-    image: alpine/git
-    commands:
-      - git clone -b develop http://kpt.kptyun.cn:3000/xuyiping/kpt-tmr-group.git
-      - ls -l
-      - pwd
+  #- name: clone
+  #  image: alpine/git
+  #  commands:
+  #    - git clone -b develop http://kpt.kptyun.cn:3000/xuyiping/kpt-tmr-group.git
+  #    - ls -l
+  #    - pwd
   - name: build
   - name: build
     image: plugins/docker
     image: plugins/docker
     volumes:
     volumes:

+ 10 - 9
Dockerfile

@@ -1,21 +1,22 @@
-FROM golang:1.17-alpine
+FROM golang:1.17-alpine as build
 
 
 LABEL name="kpt-tmr-group" \
 LABEL name="kpt-tmr-group" \
 description="pt service" \
 description="pt service" \
 owner="yiping.xu"
 owner="yiping.xu"
 
 
-WORKDIR /bin
+WORKDIR /app/kpt-tmr-group
 
 
-RUN ls -l /drone/src && \
-    pwd
+COPY . .
 
 
-RUN rm -rf /drone/src/kpt-tmr-group/bin && \
-    mkdir -p /drone/src/kpt-tmr-group/bin && \
-    GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o /drone/src/kpt-tmr-group/bin/kptTmrGroup -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-tmr-group/pod.appVersion=${version}" main.go
+RUN ls -l && pwd
 
 
+RUN rm -rf ./bin && \
+    mkdir -p ./bin && \
+    GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o ./bin/kptTmrGroup -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-tmr-group/pod.appVersion=${version}" main.go
 
 
-ADD /drone/src/kpt-tmr-group/bin/kptTmrGroup /bin/kptTmrGroup
-COPY /drone/src/kpt-tmr-group/config/*.yaml /bin/config/
+
+ADD ./bin/kptTmrGroup /bin/kptTmrGroup
+COPY ./config/*.yaml /bin/config/
 
 
 EXPOSE 8090
 EXPOSE 8090
 VOLUME /bin/logger
 VOLUME /bin/logger