30 lines
		
	
	
		
			822 B
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			822 B
		
	
	
	
		
			Docker
		
	
	
	
	
	
| # Build the Go Binary
 | |
| FROM golang:1.17 as build_sales-api
 | |
| ENV CGO_ENABLE 0
 | |
| ENV GOPROXY https://goproxy.io,direct
 | |
| ARG BUILD_REF
 | |
| 
 | |
| # Copy the source code into the container
 | |
| COPY . /service
 | |
| 
 | |
| # Build the service binary
 | |
| WORKDIR /service
 | |
| RUN go build -ldflags "-X main.build=${BUILD_REF}"
 | |
| 
 | |
| 
 | |
| # todo 设置时区
 | |
| # Run the Go Binary in Alpine
 | |
| FROM alpine:3.14
 | |
| ARG BUILD_DATE
 | |
| ARG BUILD_REF
 | |
| COPY --from=build_sales-api /service/service /service/service
 | |
| WORKDIR /service
 | |
| CMD ["./service"]
 | |
| 
 | |
| LABEL org.opencontainers.image.created="${BUILD_DATE}" \
 | |
|       org.opencontainers.image.title="service" \
 | |
|       org.opencontainers.image.author="xiaoweihong" \
 | |
|       org.opencontainers.image.source="git.hongxiaowei.com/xiaowei/service" \
 | |
|       org.opencontainers.image.revision="${BUILD_REF}" \
 | |
|       org.opencontainers.image.vendor="Xiao Wei"
 |