mirror of
				https://github.com/bufanyun/hotgo.git
				synced 2025-11-04 16:23:43 +08:00 
			
		
		
		
	优化docker镜像编译流程
This commit is contained in:
		@@ -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.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								server/manifest/docker/entrypoint.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								server/manifest/docker/entrypoint.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cd /app && ./hotgo &
 | 
				
			||||||
 | 
					echo "hotgo start all server.."
 | 
				
			||||||
 | 
					tail -f /dev/null
 | 
				
			||||||
		Reference in New Issue
	
	Block a user