diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..f58f74f --- /dev/null +++ b/.drone.yml @@ -0,0 +1,64 @@ +--- +kind: pipeline +type: docker +name: default + +volumes: + - name: gopath + host: + path: /usr/local/path/gopath + +steps: + - name: golang-build + image: golang + volumes: + - name: gopath + path: /go + commands: +# - export GOPRIVATE=gitea.241210.com + - export GOPROXY=https://goproxy.cn + - go mod init test-drone + - go mod tidy + - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test-drone + when: + target: [ "" ] + +# - name: docker-push +# image: plugins/docker +# settings: +# username: docker-push +# password: WeWlh6hGYCtxO4r +# repo: repository.241210.com/repository/gyys/drone/test-drone +# dockerfile: Dockerfile +# registry: https://repository.241210.com +# tags: ${DRONE_BUILD_NUMBER} +# when: +# target: [ "" ] +# +# - name: deployment-replace +# image: repository.241210.com/repository/base/kubectl:4 +# commands: +# - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml +# when: +# target: [ "develop","test" ] +# +# - name: deploy +# image: repository.241210.com/repository/base/kubectl:4 +# commands: +# - kubectl --kubeconfig /kube/${CI_BUILD_TARGET:-develop} apply -f deployment.yaml +# when: +# target: [ "develop","test" ] +# ## 使用参数推送稳定镜像 +# - name: deployment-replace-prod +# image: repository.241210.com/repository/base/kubectl:4 +# commands: +# - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml +# when: +# target: [ "pre","prod" ] +# +# - name: deploy-prod +# image: repository.241210.com/repository/base/kubectl:4 +# commands: +# - kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml +# when: +# target: [ "pre","prod" ] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..48c8e7b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM repository.241210.com/repository/base/alpine:3.9 + +ENV LANG C.UTF-8 +ENV LANGUAGE C.UTF-8 + +COPY test-drone /usr/local/bin/ + +RUN chmod a+x /usr/local/bin/test-drone + +RUN apk add --no-cache tzdata + +WORKDIR /usr/local/bin/ + +ENTRYPOINT ["test-drone"] diff --git a/conf.yaml b/conf.yaml new file mode 100644 index 0000000..9026a22 --- /dev/null +++ b/conf.yaml @@ -0,0 +1,5 @@ +version: 1.0.0 +serviceName: gy.micro.srv.testdrone + +env: + ver: test2 diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 0000000..eb891c9 --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-drone +spec: + replicas: 1 + selector: + matchLabels: + app: test-drone + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: test-drone + spec: + serviceAccountName: micro-account + containers: + - name: gpw + image: IMAGE_PATH:IMAGE_TAG + command: [ + "test-drone", + ] + volumeMounts: + - name: configfile + mountPath: /usr/local/bin/conf.yaml + subPath: test-drone.yaml + volumes: + - name: configfile + configMap: + name: config-center + items: + - key: test-drone.yaml + path: test-drone.yaml \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..7776ec8 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("hello world!") +}