first
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
7a381e9d52
commit
9280f9eb92
@ -1,14 +1,24 @@
|
||||
# 使用最小化的基础镜像 (Alpine)
|
||||
FROM alpine:latest
|
||||
FROM golang:1.21-alpine AS builder
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
WORKDIR /workspace
|
||||
|
||||
# 将编译好的可执行文件复制到容器内的工作目录
|
||||
COPY myapp /app/
|
||||
# 将代码复制到容器内(你也可以选择在构建过程中通过挂载代码)
|
||||
COPY . .
|
||||
|
||||
# 暴露容器的端口
|
||||
# 设置 Go 模块缓存和构建缓存目录
|
||||
ENV GOMODCACHE=/go/pkg/mod
|
||||
ENV GOCACHE=/go/cache
|
||||
|
||||
# 执行 go mod tidy 来同步和清理模块依赖
|
||||
RUN go mod tidy
|
||||
|
||||
# 编译可执行文件
|
||||
RUN go build -o myapp -ldflags "-X main.RunMode=test -s -w"
|
||||
|
||||
# 暴露容器端口
|
||||
EXPOSE 11000
|
||||
|
||||
# 设置容器启动时执行的命令
|
||||
# 运行应用程序
|
||||
CMD ["./myapp"]
|
||||
|
Loading…
Reference in new issue