forked from CareyWang/MyUrls
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (25 loc) · 822 Bytes
/
Dockerfile
File metadata and controls
34 lines (25 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM golang:1.22-alpine AS build
ARG TARGETARCH
RUN apk add --update git
RUN git clone https://github.com/CareyWang/MyUrls /app
WORKDIR /app
# 组合使用多个镜像源(推荐腾讯云+七牛云)
#RUN go env -w GOPROXY="https://mirrors.cloud.tencent.com/go/,https://goproxy.cn,direct"
# 禁用校验和数据库(重要)
RUN go env -w GOSUMDB=off
# 启用模块代理回退机制
RUN go env -w GONOPROXY=""
# 先尝试下载依赖
RUN go mod download || go mod download -retry 3
# 再执行 tidy 操作
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o myurls
FROM alpine:latest
WORKDIR /app
COPY --from=build /app/myurls ./
COPY public/* ./public/
COPY start.sh ./
COPY start.sh ./
RUN chmod +x start.sh
EXPOSE 8080
ENTRYPOINT ["/bin/sh", "/app/start.sh"]