Browse Source

dpr:8

master
zhipeng.hu 1 year ago
parent
commit
fbc2c9409f
  1. 46
      .drone.yml
  2. 15
      main.go

46
.drone.yml

@ -9,30 +9,30 @@ volumes:
path: /usr/local/path/gopath path: /usr/local/path/gopath
steps: steps:
# - name: golang-build
# image: golang:1.17-alpine3.15
# volumes:
# - name: gopath
# path: /go
# commands:
# - 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: [ "test","pre" ]
- name: docker-push
image: plugins/docker
settings:
username: tjqmhu
password: tjqm4912
repo: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone
dockerfile: Dockerfile
registry: https://registry.cn-hangzhou.aliyuncs.com
tags: ${DRONE_BUILD_NUMBER}
- name: golang-build
image: golang:1.17-alpine3.15
volumes:
- name: gopath
path: /go
commands:
- 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: when:
target: [ "test","pre"]
target: [ "test","pre" ]
# - name: docker-push
# image: plugins/docker
# settings:
# username: tjqmhu
# password: tjqm4912
# repo: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone
# dockerfile: Dockerfile
# registry: https://registry.cn-hangzhou.aliyuncs.com
# tags: ${DRONE_BUILD_NUMBER}
# when:
# target: [ "test","pre"]
- name: rancher-deploy - name: rancher-deploy
image: registry.cn-hangzhou.aliyuncs.com/hvp/dpr:8 # 直接用busybox image: registry.cn-hangzhou.aliyuncs.com/hvp/dpr:8 # 直接用busybox

15
main.go

@ -1,20 +1,9 @@
package main package main
// 导入gin包
import "github.com/gin-gonic/gin"
import "fmt"
// 入口函数 // 入口函数
func main() { func main() {
// 初始化一个http服务对象 // 初始化一个http服务对象
r := gin.Default()
// 设置一个get请求的路由,url为/ping, 处理函数(或者叫控制器函数)是一个闭包函数。
r.GET("/", func(c *gin.Context) {
// 通过请求上下文对象Context, 直接往客户端返回一个json
c.JSON(200, gin.H{
"message": "pong9",
})
})
r.Run(":8080") // 监听并在 0.0.0.0:8080 上启动服务
fmt.Println("ssss1")
} }
Loading…
Cancel
Save