Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
7a66b2b63b | |||
859ebb3206 | |||
232fe8fc22 | |||
00269b7d29 | |||
50135c7231 | |||
fde4c5e69e | |||
f306ccbb22 | |||
823007532a | |||
29ccfea57a | |||
70adc6dbf1 | |||
8c33fe20fc | |||
63717f5327 |
74
.drone.yml
74
.drone.yml
@ -1,10 +1,37 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
|
||||
#设置挂载
|
||||
volumes:
|
||||
#Go编译缓存
|
||||
- name: pkgdeps
|
||||
host:
|
||||
path: /mnt/drone/cache/go
|
||||
|
||||
clone:
|
||||
disable: false # 启用代码拉取
|
||||
|
||||
steps:
|
||||
#构建镜像
|
||||
- name: build
|
||||
image: golang:latest
|
||||
pull: if-not-exists
|
||||
volumes:
|
||||
- name: pkgdeps
|
||||
path: /go/pkg
|
||||
environment:
|
||||
GOPROXY: "https://goproxy.cn,direct" # 懂的都懂
|
||||
commands:
|
||||
- echo "start build app"
|
||||
- CGO_ENABLED=0 go build -o cli -ldflags="-w -s"
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
- dev
|
||||
event:
|
||||
- push
|
||||
|
||||
# 开发版
|
||||
- name: docker-${DRONE_BRANCH}
|
||||
image: plugins/docker
|
||||
@ -18,7 +45,7 @@ steps:
|
||||
debug: true
|
||||
dockerfile: Dockerfile
|
||||
tags:
|
||||
- canary
|
||||
- latest
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
@ -26,25 +53,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:
|
||||
@ -60,7 +68,7 @@ steps:
|
||||
script:
|
||||
- echo "deploy docker ssh!"
|
||||
- name=drone-test
|
||||
- image=git.daymele.com/liupeng/drone:canary
|
||||
- image=git.daymele.com/liupeng/drone:latest
|
||||
- echo ${DRONE_BRANCH}
|
||||
- docker pull $image
|
||||
- docker rm -f drone-test || true
|
||||
@ -74,26 +82,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
|
||||
|
||||
|
41
Dockerfile
41
Dockerfile
@ -1,23 +1,32 @@
|
||||
# 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 as builder
|
||||
# ENV GO111MODULE on
|
||||
# ENV GOPROXY=https://goproxy.io
|
||||
# WORKDIR /src
|
||||
# RUN groupadd -r appuser && useradd --no-log-init -r -g appuser appuser
|
||||
# 通过提前运行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 . .
|
||||
# RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||
# GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o /bin/cli -ldflags="-w -s"
|
||||
|
||||
|
||||
# 生成alpine部署容器
|
||||
FROM alpine:latest
|
||||
FROM scratch as client
|
||||
LABEL MAINTAINER='LIU Peng<liupeng@daymele.com>'
|
||||
WORKDIR /
|
||||
COPY --from=build /adapt /adapt
|
||||
|
||||
# 健康检测
|
||||
ADD ./hc.sh /root/healthcheck.sh
|
||||
HEALTHCHECK --start-period=60s --interval=15s --timeout=5s --retries=3 CMD /bin/ash /root/healthcheck.sh
|
||||
# COPY --from=builder /bin/cli /cli
|
||||
# COPY --from=builder /etc/passwd /etc/passwd
|
||||
# COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
# COPY --from=builder /bin/appmain /bin/appmain
|
||||
# USER appuser
|
||||
COPY ./cli /cli
|
||||
# 健康检测 scratch 镜像没有其它shell指令,所以无法进行健康检测
|
||||
# ADD ./hc.sh /root/healthcheck.sh
|
||||
# HEALTHCHECK --start-period=60s --interval=15s --timeout=5s --retries=3 CMD /bin/ash /root/healthcheck.sh
|
||||
|
||||
# 时区处理(方法一:需要提前准备下两条,scratch和alpine都可以使用)
|
||||
# tar cfz zoneinfo.tar.gz /usr/share/zoneinfo
|
||||
@ -30,7 +39,7 @@ ADD zoneinfo.tar.gz /
|
||||
# && echo "Asia/Shanghai" > /etc/timezone \
|
||||
# && apk del tzdata \
|
||||
# && rm -rf /var/cache/apk/*
|
||||
ENTRYPOINT ["/adapt","-port","9000","-conf","/conf/daymele.conf"]
|
||||
ENTRYPOINT ["/cli","-port","9000","-conf","/conf/daymele.conf"]
|
||||
EXPOSE 9000
|
||||
|
||||
# docker image prune 删除悬虚镜像
|
||||
|
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