环境变量测试

This commit is contained in:
徐俊杰 2023-04-07 10:20:05 +08:00
parent 458c5e3bc8
commit 338439db59
3 changed files with 6 additions and 2 deletions

View File

@ -5,7 +5,7 @@ cd ..
go build -ldflags "-s -w" -o ./build/artistinfo-dev ./cmd/app.go
docker rmi artistinfo-dev
docker rmi 121.229.45.214:9006/artistinfo-dev
docker build . -f .\DockerfileWindowsTest -t artistinfo-dev
docker build . --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -f .\DockerfileWindowsTest -t artistinfo-dev
docker tag artistinfo-dev 121.229.45.214:9006/artistinfo-dev
docker push 121.229.45.214:9006/artistinfo-dev
pause

View File

@ -15,4 +15,5 @@ WORKDIR /app/main-client/bin
ARG BUILD_DATE
ENV BUILD_DATE ${BUILD_DATE}
# 在容器启动时输出环境变量BUILD_DATE的值
CMD ['echo "Container was built on: ${BUILD_DATE}" &&./mainServer']
# CMD ['echo "Container was built on: ${BUILD_DATE}" &&./mainServer']
CMD ["./mainServer"]

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"os"
"dubbo.apache.org/dubbo-go/v3/config"
@ -27,5 +28,7 @@ func main() {
if err := config.Load(); err != nil {
panic(err)
}
buildDate := os.Getenv("BUILD_DATE")
fmt.Println("镜像生成时间:", buildDate)
select {}
}