Skip to content

Commit 0c33a72

Browse files
committed
feat:docker镜像发布
1 parent bbf3037 commit 0c33a72

36 files changed

+28
-77
lines changed

Dockerfile

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ RUN apk add --no-cache yarn
1010

1111
WORKDIR /app/chuan-next
1212

13-
# 前端依赖和构建
14-
COPY chuan-next/package.json chuan-next/yarn.lock ./
15-
RUN yarn install --frozen-lockfile --network-timeout 300000
16-
13+
# 复制所有源代码(确保获取最新代码)
1714
COPY chuan-next/ ./
1815

1916
# 清理构建文件(模拟 build-fullstack.sh 的 clean_all 函数)
2017
RUN rm -rf .next out
2118

19+
# 前端依赖和构建
20+
COPY chuan-next/package.json chuan-next/yarn.lock ./
21+
RUN yarn install --frozen-lockfile --network-timeout 300000
22+
2223
# 临时移除 API 目录进行 SSG 构建(模拟 build-fullstack.sh 的 build_frontend 函数)
2324
RUN if [ -d "src/app/api" ]; then mv src/app/api /tmp/api-backup; fi && \
24-
NEXT_EXPORT=true NODE_ENV=production NEXT_PUBLIC_BACKEND_URL= NEXT_PUBLIC_WS_URL= NEXT_PUBLIC_API_BASE_URL= SKIP_TYPESCRIPT_CHECK=true yarn build && \
25+
NEXT_EXPORT=true NODE_ENV=production NEXT_PUBLIC_BACKEND_URL= NEXT_PUBLIC_WS_URL= NEXT_PUBLIC_API_BASE_URL= yarn build && \
2526
if [ -d "/tmp/api-backup" ]; then mv /tmp/api-backup src/app/api; fi
2627

2728
# ==============================================
@@ -39,21 +40,16 @@ ENV GOARCH=amd64
3940

4041
WORKDIR /app
4142

43+
# 先复制所有源代码(确保获取最新代码)
44+
COPY . .
45+
4246
# Go 依赖
4347
COPY go.mod go.sum ./
4448
RUN go mod download
4549

46-
# 清理嵌入的前端文件(模拟 build-fullstack.sh 的 copy_frontend_files 函数)
47-
RUN mkdir -p ./internal/web/frontend && \
48-
find ./internal/web/frontend -type f ! -name ".gitkeep" -delete 2>/dev/null || true
49-
5050
# 拷贝前端构建结果
5151
COPY --from=frontend-builder /app/chuan-next/out ./internal/web/frontend/
5252

53-
# Go 源码
54-
COPY cmd/ ./cmd/
55-
COPY internal/ ./internal/
56-
5753
# 构建 Go 应用 - AMD64 架构(模拟 build-fullstack.sh 的 build_backend 函数)
5854
RUN go build -ldflags='-s -w -extldflags '-static'' -o server ./cmd
5955

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ cd file-transfer-go
8989
docker-compose up -d
9090

9191
# 或者直接使用 Docker 镜像
92-
docker run -d -p 8080:8080 --name file-transfer-go matrixseven/file-transfer:latest
92+
docker run -d -p 8080:8080 --name file-transfer-go matrixseven/file-transfer-go:latest
9393
```
9494

9595
### 方式二:本地构建部署

docker-compose.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
version: '3.8'
22

33
services:
4-
file-transfer-go:
5-
build: .
6-
ports:
7-
- "8080:8080"
8-
environment:
9-
- NODE_ENV=production
10-
restart: unless-stopped
11-
healthcheck:
12-
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080"]
13-
interval: 30s
14-
timeout: 10s
15-
retries: 3
16-
start_period: 40s
17-
18-
# 可选:使用已发布的镜像
19-
# file-transfer-go:
20-
# image: matrixseven/file-transfer:latest
4+
# file-transfer-go:
5+
# build: .
216
# ports:
227
# - "8080:8080"
8+
# environment:
9+
# - NODE_ENV=production
2310
# restart: unless-stopped
11+
# healthcheck:
12+
# test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080"]
13+
# interval: 30s
14+
# timeout: 10s
15+
# retries: 3
16+
# start_period: 40s
17+
file-transfer-go:
18+
image: matrixseven/file-transfer-go:latest
19+
ports:
20+
- "8080:8080"
21+
restart: unless-stopped

internal/web/frontend/.gitkeep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Static Files Directory
2+
3+
This directory contains static files that will be embedded into the Go binary.

internal/web/frontend/404.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/web/frontend/404/index.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/web/frontend/_next/static/chunks/103-a63863fe5831e6e4.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/web/frontend/_next/static/chunks/4bd1b696-cf72ae8a39fa05aa.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/web/frontend/_next/static/chunks/964-50c6a19159c7d466.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/web/frontend/_next/static/chunks/app/_not-found/page-c2dc73355084795c.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)