docker build
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
liupeng 2024-03-01 16:10:53 +08:00
parent 823007532a
commit f306ccbb22
2 changed files with 49 additions and 47 deletions

View File

@ -46,6 +46,8 @@ steps:
GOPROXY: "https://goproxy.cn,direct" # 懂的都懂
commands:
- CGO_ENABLED=0 go build -o adapt -ldflags="-w -s"
- docker build -t git.daymele.com/liupeng/drone .
- docker push git.daymele.com/liupeng/drone
when:
branch:
- master
@ -55,25 +57,25 @@ steps:
#推送镜像至镜像仓库
- name: publish
image: plugins/docker
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: publish
# image: plugins/docker
# 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
@ -92,25 +94,25 @@ steps:
# - docker rmi $(docker images | grep go-fblsj/person-api | grep none | awk '{print $3}')
# 开发版
# - name: docker-${DRONE_BRANCH}
# image: plugins/docker
# settings:
# username: liupeng
# password:
# from_secret: DOCKER_PASSWORD
# registry: git.daymele.com
# repo: git.daymele.com/liupeng/drone
# insecure: true
# debug: true
# dockerfile: Dockerfile
# tags:
# - canary
# when:
# branch:
# - master
# - dev
# event:
# - push
- name: docker-${DRONE_BRANCH}
image: plugins/docker
settings:
username: liupeng
password:
from_secret: DOCKER_PASSWORD
registry: git.daymele.com
repo: git.daymele.com/liupeng/drone
insecure: true
debug: true
dockerfile: Dockerfile
tags:
- latest
when:
branch:
- master
- dev
event:
- push
# 稳定版
# - name: docker-release

View File

@ -1,19 +1,19 @@
# golang环境编译 docker build -t dev.daymele.com:5000/res .
FROM golang:latest as build
ENV GO111MODULE on
ENV GOPROXY=https://goproxy.io
WORKDIR /
# FROM golang:latest as build
# ENV GO111MODULE on
# ENV GOPROXY=https://goproxy.io
# WORKDIR /
# 通过提前运行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"
# COPY go.mod go.sum ./
# RUN go mod download
# ADD . /
# RUN GOOS=linux CGO_ENABLED=0 go build -o adapt -ldflags="-w -s"
# 生成alpine部署容器
FROM alpine:latest
LABEL MAINTAINER='LIU Peng<liupeng@daymele.com>'
WORKDIR /
COPY --from=build /adapt /adapt
COPY ./adapt /adapt
# 健康检测
ADD ./hc.sh /root/healthcheck.sh