This commit is contained in:
parent
00269b7d29
commit
232fe8fc22
35
.drone.yml
35
.drone.yml
@ -14,30 +14,27 @@ clone:
|
||||
|
||||
steps:
|
||||
#构建镜像
|
||||
# - 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: 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 cli -ldflags="-w -s"
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
- dev
|
||||
event:
|
||||
- push
|
||||
|
||||
# 开发版
|
||||
- name: docker-${DRONE_BRANCH}
|
||||
image: plugins/docker
|
||||
settings:
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
DOCKER_CLI_EXPERIMENTAL: "enabled"
|
||||
username: liupeng
|
||||
password:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
|
30
Dockerfile
30
Dockerfile
@ -1,26 +1,24 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
FROM golang:1.22-alpine as base
|
||||
ENV GO111MODULE on
|
||||
ENV GOPROXY=https://goproxy.io
|
||||
WORKDIR /src
|
||||
# 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 --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"
|
||||
# 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 go build -o /bin/cli -ldflags="-w -s"
|
||||
|
||||
|
||||
# 生成alpine部署容器
|
||||
FROM scratch as client
|
||||
LABEL MAINTAINER='LIU Peng<liupeng@daymele.com>'
|
||||
WORKDIR /
|
||||
COPY --from=build-client /bin/adapt /adapt
|
||||
# COPY --from=build-client /bin/cli /cli
|
||||
COPY ./cli /cli
|
||||
|
||||
# 健康检测
|
||||
ADD ./hc.sh /root/healthcheck.sh
|
||||
@ -37,7 +35,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 删除悬虚镜像
|
||||
|
Loading…
Reference in New Issue
Block a user