-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (34 loc) · 862 Bytes
/
Dockerfile
File metadata and controls
49 lines (34 loc) · 862 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 前端构建阶段
FROM node:18-alpine AS frontend-builder
# 设置工作目录
WORKDIR /app
# 复制前端项目文件
COPY . ./
RUN npm install
# 构建前端项目
RUN npm run build
# 后端构建阶段
FROM golang:alpine AS backend-builder
# 设置工作目录
WORKDIR /app
# 复制 go.mod 和 go.sum
COPY go.mod go.sum ./
# 下载依赖
RUN go mod download
# 复制源代码
COPY . .
# 构建应用
RUN CGO_ENABLED=0 go build -o mail-push
# 最终运行阶段
FROM alpine:latest
# 安装 ca-certificates,用于 SMTP SSL 连接
RUN apk --no-cache add ca-certificates
WORKDIR /app
# 从构建阶段复制二进制文件和必要的文件
COPY --from=backend-builder /app/mail-push .
COPY --from=backend-builder /app/config.toml .
COPY --from=frontend-builder /app/build ./build
# 暴露端口
EXPOSE 8080
# 运行应用
CMD ["./mail-push"]