This commit is contained in:
parent
fde4c5e69e
commit
50135c7231
129
.drone.yml
129
.drone.yml
@ -8,88 +8,28 @@ volumes:
|
||||
- name: pkgdeps
|
||||
host:
|
||||
path: /mnt/drone/cache/go
|
||||
#Docker环境
|
||||
- name: dockersock
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
#Docker配置
|
||||
- name: docker-daemon
|
||||
host:
|
||||
path: /etc/docker/daemon.conf
|
||||
|
||||
clone:
|
||||
disable: false # 启用代码拉取
|
||||
|
||||
steps:
|
||||
#设置缓存
|
||||
# - name: load cache
|
||||
# image: drillster/drone-volume-cache
|
||||
# privileged: true
|
||||
# network_mode: host
|
||||
# # 将宿主机的 docker和配置挂载到运行的 docker 容器中,那么在容器中运行 docker 命令时,等同于在宿主机中运行该docker 命令
|
||||
# volumes:
|
||||
# - name: docker_sock
|
||||
# path: /var/run/docker.sock
|
||||
# - name: images
|
||||
# path: /images
|
||||
# - name: docker-daemon
|
||||
# path: /etc/docker/daemon.conf
|
||||
|
||||
#构建镜像
|
||||
- name: build
|
||||
image: golang:latest
|
||||
pull: if-not-exists
|
||||
volumes:
|
||||
- name: pkgdeps
|
||||
path: /go/pkg
|
||||
environment:
|
||||
GOPROXY: "https://goproxy.cn,direct" # 懂的都懂
|
||||
commands:
|
||||
- CGO_ENABLED=0 go build -o adapt -ldflags="-w -s"
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
- dev
|
||||
event:
|
||||
- push
|
||||
|
||||
|
||||
#推送镜像至镜像仓库
|
||||
# - name: publish
|
||||
# image: plugins/docker
|
||||
# - name: build
|
||||
# image: golang:latest
|
||||
# pull: if-not-exists
|
||||
# volumes:
|
||||
# - name: docker
|
||||
# path: /var/run/docker.sock
|
||||
# - name: pkgdeps
|
||||
# path: /cache
|
||||
# # mirrors: #镜像仓库加速地址,不需要加速,可以直接删除
|
||||
# # from_secret: registry_mirrors
|
||||
# settings:
|
||||
# purge: false
|
||||
# registry: git.daymele.com
|
||||
# repo: git.daymele.com/liupeng/drone
|
||||
# tags:
|
||||
# - latest
|
||||
# username: liupeng
|
||||
# password: #镜像仓库密码
|
||||
# from_secret: DOCKER_PASSWORD
|
||||
|
||||
#部署镜像服务
|
||||
# - name: ssh commands
|
||||
# image: appleboy/drone-ssh
|
||||
# pull: if-not-exists
|
||||
# settings:
|
||||
# host: dev.daymele.com
|
||||
# port: 22
|
||||
# username:
|
||||
# from_secret: liup
|
||||
# key:
|
||||
# from_secret: HOST_KEY
|
||||
# script:
|
||||
# - cd /home/dockerConfig/project/go-gin
|
||||
# - docker-compose pull && docker-compose up --force-recreate -d
|
||||
# - docker rmi $(docker images | grep go-fblsj/person-api | grep none | awk '{print $3}')
|
||||
# path: /go/pkg
|
||||
# environment:
|
||||
# GOPROXY: "https://goproxy.cn,direct" # 懂的都懂
|
||||
# commands:
|
||||
# - CGO_ENABLED=0 go build -o adapt -ldflags="-w -s"
|
||||
# when:
|
||||
# branch:
|
||||
# - master
|
||||
# - dev
|
||||
# event:
|
||||
# - push
|
||||
|
||||
# 开发版
|
||||
- name: docker-${DRONE_BRANCH}
|
||||
@ -112,25 +52,6 @@ steps:
|
||||
event:
|
||||
- push
|
||||
|
||||
# 稳定版
|
||||
# - name: docker-release
|
||||
# image: plugins/docker
|
||||
# settings:
|
||||
# username: liupeng
|
||||
# password:
|
||||
# from_secret: DOCKER_PASSWORD
|
||||
# registry: git.daymele.com
|
||||
# repo: git.daymele.com/liupeng/drone
|
||||
# insecure: true
|
||||
# dockerfile: Dockerfile
|
||||
# tags:
|
||||
# - ${DRONE_TAG}
|
||||
# - latest
|
||||
# when:
|
||||
# event:
|
||||
# - tag
|
||||
|
||||
|
||||
- name: deploy-${DRONE_BRANCH}
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
@ -160,28 +81,4 @@ steps:
|
||||
- push
|
||||
|
||||
|
||||
# - name: deploy-release
|
||||
# image: appleboy/drone-ssh
|
||||
# settings:
|
||||
# host:
|
||||
# - pub.daymele.com
|
||||
# username: liup
|
||||
# # password:
|
||||
# # from_secret: HOST_PASSWORD
|
||||
# key:
|
||||
# from_secret: HOST_KEY
|
||||
# port: 22
|
||||
# command_timeout: 2m
|
||||
# script:
|
||||
# - echo "deploy podman ssh!"
|
||||
# - name=drone-release
|
||||
# - image=git.daymele.com/liupeng/drone:latest
|
||||
# - podman pull $image
|
||||
# - podman rm -f drone-release || true
|
||||
# - podman image prune -f
|
||||
# - podman run --name=$name -d -p 8002:9000 -v /etc/conf:/conf $image
|
||||
# when:
|
||||
# event:
|
||||
# - tag
|
||||
|
||||
|
||||
|
27
Dockerfile
27
Dockerfile
@ -1,19 +1,26 @@
|
||||
# golang环境编译 docker build -t dev.daymele.com:5000/res .
|
||||
# FROM golang:latest as build
|
||||
# ENV GO111MODULE on
|
||||
# ENV GOPROXY=https://goproxy.io
|
||||
# WORKDIR /
|
||||
# syntax=docker/dockerfile:1.2
|
||||
FROM golang:1.22-alpine as base
|
||||
ENV GO111MODULE on
|
||||
ENV GOPROXY=https://goproxy.io
|
||||
WORKDIR /src
|
||||
# 通过提前运行go mod download可以使用cache编译,避免每次编译都下载,加快编译速度
|
||||
# COPY go.mod go.sum ./
|
||||
# RUN go mod download
|
||||
# ADD . /
|
||||
# RUN GOOS=linux CGO_ENABLED=0 go build -o adapt -ldflags="-w -s"
|
||||
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||
--mount=type=bind,source=/go.sum,target=/go.sum \
|
||||
--mount=type=bind,source=/go.mod,target=/go.mod \
|
||||
go mod download -x
|
||||
COPY . .
|
||||
|
||||
FROM base AS build-client
|
||||
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||
GOOS=linux CGO_ENABLED=0 go build -o /bin/adapt -ldflags="-w -s"
|
||||
|
||||
|
||||
# 生成alpine部署容器
|
||||
FROM alpine:latest
|
||||
FROM scratch as client
|
||||
LABEL MAINTAINER='LIU Peng<liupeng@daymele.com>'
|
||||
WORKDIR /
|
||||
COPY ./adapt /adapt
|
||||
COPY --from=build-client /bin/adapt /adapt
|
||||
|
||||
# 健康检测
|
||||
ADD ./hc.sh /root/healthcheck.sh
|
||||
|
4
dqres.go
4
dqres.go
@ -53,7 +53,7 @@ func Mkdir(basePath string) string {
|
||||
}
|
||||
|
||||
func main() {
|
||||
version := "1.0.0"
|
||||
version := "1.0.2"
|
||||
fmt.Printf("\n\n\n")
|
||||
fmt.Printf(" **************************************************\n")
|
||||
fmt.Printf(" * \033[1;34;42m豆曲咖资源|美团服务\033[0m *\n")
|
||||
@ -124,7 +124,7 @@ func main() {
|
||||
}
|
||||
}()
|
||||
// 等待中断信号以优雅地关闭服务器(设置 5 秒的超时时间)
|
||||
quit := make(chan os.Signal)
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, os.Interrupt)
|
||||
<-quit
|
||||
logger.Info("Shutdown Server ...")
|
||||
|
Loading…
Reference in New Issue
Block a user