Merge pull request #24 from bufanyun/v2.0

优化docker镜像编译流程
This commit is contained in:
maxbad 2023-06-12 14:58:47 +08:00 committed by GitHub
commit d982172f67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 19 deletions

View File

@ -110,22 +110,11 @@ start:
make port; make port;
# Build docker image. # Build docker image and commit to the repository.
# example: make image tag=v0.0.1
.PHONY: image .PHONY: image
image: cli.install image:
$(eval _TAG = $(shell git log -1 --format="%cd.%h" --date=format:"%Y%m%d%H%M%S")) @echo "y" | gf docker main.go -p -tn hotgo:$(tag)
ifneq (, $(shell git status --porcelain 2>/dev/null))
$(eval _TAG = $(_TAG).dirty)
endif
$(eval _TAG = $(if ${TAG}, ${TAG}, $(_TAG)))
$(eval _PUSH = $(if ${PUSH}, ${PUSH}, ))
@gf docker -p -b "-a amd64 -s linux -p temp" -t $(DOCKER_NAME):${_TAG};
# Build docker image and automatically push to docker repo.
.PHONY: image.push
image.push:
@make image PUSH=-p;
# Deploy image and yaml to current kubectl environment. # Deploy image and yaml to current kubectl environment.

View File

@ -13,6 +13,13 @@ gfcli:
output: "./temp/hotgo" # 可执行文件生成路径 output: "./temp/hotgo" # 可执行文件生成路径
extra: "" extra: ""
docker:
build: "-a amd64 -s linux -p temp -ew" # 构建参数
tagPrefixes: # 该docker的标记前缀用于docker推送请替换成你自己的
- ccr.ccs.tencentyun.com/bufanyun
gen: gen:
dao: dao:
- link: "mysql:hotgo:hg123456.@tcp(127.0.0.1:3306)/hotgo?loc=Local&parseTime=true" - link: "mysql:hotgo:hg123456.@tcp(127.0.0.1:3306)/hotgo?loc=Local&parseTime=true"
@ -26,6 +33,7 @@ gfcli:
gJsonSupport: true gJsonSupport: true
clear: false clear: false
# service: # 生成业务配置 # service: # 生成业务配置
# srcFolder: "internal/logic" # srcFolder: "internal/logic"
# dstFolder: "internal/service" # dstFolder: "internal/service"

View File

@ -5,12 +5,19 @@ FROM loads/alpine:3.8
############################################################################### ###############################################################################
ENV WORKDIR /app ENV WORKDIR /app
ADD resource $WORKDIR/ ADD hack $WORKDIR/hack/
ADD ./temp/linux_amd64/main $WORKDIR/main ADD manifest/config $WORKDIR/manifest/config/
RUN chmod +x $WORKDIR/main ADD resource $WORKDIR/resource/
ADD ./temp/linux_amd64/hotgo $WORKDIR/hotgo
ADD ./manifest/docker/entrypoint.sh $WORKDIR/entrypoint.sh
RUN chmod +x $WORKDIR/hotgo
RUN chmod +x $WORKDIR/entrypoint.sh
############################################################################### ###############################################################################
# START # START
############################################################################### ###############################################################################
WORKDIR $WORKDIR WORKDIR $WORKDIR
CMD ./main CMD ./entrypoint.sh

View File

@ -0,0 +1,5 @@
#!/bin/bash
cd /app && ./hotgo &
echo "hotgo start all server.."
tail -f /dev/null