报错:
[2024-10-09 22:36:37] ERROR: failed to solve: process "/bin/sh -c go build -o main ." did not complete successfully: exit code: 1
[2024-10-09 22:36:37] [Pipeline] }
[2024-10-09 22:36:37] [Pipeline] // stage
[2024-10-09 22:36:37] [Pipeline] stage
[2024-10-09 22:36:37] [Pipeline] { (推送 Docker 镜像到 TCR)
[2024-10-09 22:36:37] Stage "推送 Docker 镜像到 TCR" skipped due to earlier failure(s)
[2024-10-09 22:36:37] [Pipeline] }
[2024-10-09 22:36:37] [Pipeline] // stage
[2024-10-09 22:36:37] [Pipeline] }
[2024-10-09 22:36:37] [Pipeline] // node
[2024-10-09 22:36:37] [Pipeline] End of Pipeline
[2024-10-09 22:36:37] ERROR: script returned exit code 1
[2024-10-09 22:36:37] Finished: FAILURE
***
我的dokerfile
# 使用官方的Golang镜像作为基础镜像
FROM golang:latest AS builder
# 设置工作目录
WORKDIR /app
# 复制项目的源代码到容器中
COPY . .
# 构建项目(假设您的主程序是main.go,并且它位于项目的根目录下)
RUN go build -o main .
# 使用一个轻量级的镜像来运行构建好的二进制文件
FROM alpine:latest
# 设置工作目录
WORKDIR /root/
# 复制构建好的二进制文件到容器中
COPY --from=builder /app/main .
# 暴露应用运行的端口(根据您的项目实际使用的端口进行修改)
EXPOSE 80
# 运行应用
CMD ["./main"]
我的项目目录
需要注意下dockerfile的build部分
可以先在本地调试运行来分析