diff --git a/server/Makefile b/server/Makefile index ba7cfdb..dc2fa85 100644 --- a/server/Makefile +++ b/server/Makefile @@ -110,22 +110,11 @@ start: make port; -# Build docker image. +# Build docker image and commit to the repository. +# example: make image tag=v0.0.1 .PHONY: image -image: cli.install - $(eval _TAG = $(shell git log -1 --format="%cd.%h" --date=format:"%Y%m%d%H%M%S")) -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; +image: + @echo "y" | gf docker main.go -p -tn hotgo:$(tag) # Deploy image and yaml to current kubectl environment. diff --git a/server/hack/config.yaml b/server/hack/config.yaml index 1b02d63..38ced50 100644 --- a/server/hack/config.yaml +++ b/server/hack/config.yaml @@ -13,6 +13,13 @@ gfcli: output: "./temp/hotgo" # 可执行文件生成路径 extra: "" + + docker: + build: "-a amd64 -s linux -p temp -ew" # 构建参数 + tagPrefixes: # 该docker的标记前缀,用于docker推送,请替换成你自己的 + - ccr.ccs.tencentyun.com/bufanyun + + gen: dao: - link: "mysql:hotgo:hg123456.@tcp(127.0.0.1:3306)/hotgo?loc=Local&parseTime=true" @@ -26,6 +33,7 @@ gfcli: gJsonSupport: true clear: false + # service: # 生成业务配置 # srcFolder: "internal/logic" # dstFolder: "internal/service" diff --git a/server/manifest/docker/Dockerfile b/server/manifest/docker/Dockerfile index d3abe8f..f36b107 100644 --- a/server/manifest/docker/Dockerfile +++ b/server/manifest/docker/Dockerfile @@ -5,12 +5,19 @@ FROM loads/alpine:3.8 ############################################################################### ENV WORKDIR /app -ADD resource $WORKDIR/ -ADD ./temp/linux_amd64/main $WORKDIR/main -RUN chmod +x $WORKDIR/main +ADD hack $WORKDIR/hack/ +ADD manifest/config $WORKDIR/manifest/config/ +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 ############################################################################### + WORKDIR $WORKDIR -CMD ./main +CMD ./entrypoint.sh + diff --git a/server/manifest/docker/entrypoint.sh b/server/manifest/docker/entrypoint.sh new file mode 100644 index 0000000..e8f6e9b --- /dev/null +++ b/server/manifest/docker/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd /app && ./hotgo & +echo "hotgo start all server.." +tail -f /dev/null \ No newline at end of file