|
@@ -160,6 +160,10 @@ FROM ${REGISTRY}/golang:1.24-alpine AS builder
|
|
|
```
|
|
|
go: cannot write multiple packages to non-directory ./bin/server
|
|
|
```
|
|
|
+或
|
|
|
+```
|
|
|
+go: cannot write multiple packages to non-directory ./bin/server/main
|
|
|
+```
|
|
|
|
|
|
需要修改Dockerfile中的以下内容:
|
|
|
|
|
@@ -172,7 +176,7 @@ RUN export GOPROXY=https://goproxy.cn,direct && go mod tidy && go build -ldflags
|
|
|
更改为:
|
|
|
```dockerfile
|
|
|
RUN mkdir -p /data/app/bin/
|
|
|
-RUN export GOPROXY=https://goproxy.cn,direct && go mod tidy && go build -ldflags="-s -w" -o ./bin/server/main ${APP_RELATIVE_PATH}
|
|
|
+RUN export GOPROXY=https://goproxy.cn,direct && go mod tidy && go build -ldflags="-s -w" -o ./bin/app ${APP_RELATIVE_PATH}
|
|
|
```
|
|
|
|
|
|
2. 同时需要更新ENTRYPOINT:
|
|
@@ -182,9 +186,11 @@ ENTRYPOINT [ "./server" ]
|
|
|
|
|
|
更改为:
|
|
|
```dockerfile
|
|
|
-ENTRYPOINT [ "./server/main" ]
|
|
|
+ENTRYPOINT [ "./app" ]
|
|
|
```
|
|
|
|
|
|
+这种方式可以确保编译输出是一个单一的可执行文件,而不是目录结构,避免多包编译问题。
|
|
|
+
|
|
|
## 验证部署
|
|
|
部署完成后,您可以通过以下方式验证服务是否正常运行:
|
|
|
|