Browse Source

test

master
zhipeng.hu 3 years ago
parent
commit
000dff5174
  1. 64
      .drone.yml
  2. 14
      Dockerfile
  3. 5
      conf.yaml
  4. 35
      deployment.yaml
  5. 7
      main.go

64
.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" ]

14
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"]

5
conf.yaml

@ -0,0 +1,5 @@
version: 1.0.0
serviceName: gy.micro.srv.testdrone
env:
ver: test2

35
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

7
main.go

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("hello world!")
}
Loading…
Cancel
Save