Skip to content

Commit 72a4f20

Browse files
authored
Merge pull request #62 from Lirzh/main
将包管理器换成npm以统一,并适配 egdeone,并支持docker
2 parents 1bd39c8 + 3b5df81 commit 72a4f20

10 files changed

Lines changed: 8557 additions & 5735 deletions

File tree

.github/workflows/build-docker.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
inputs:
10+
reason:
11+
description: 'Reason for manual trigger'
12+
required: false
13+
default: 'Manual trigger'
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v6
29+
with:
30+
fetch-depth: '0'
31+
32+
# 安装 Node.js
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 22
37+
cache: 'npm'
38+
39+
- name: Install dependencies and build
40+
run: |
41+
npm ci
42+
npm run build
43+
44+
# 提取版本号
45+
- name: Extract version from package.json
46+
id: extract-version
47+
run: |
48+
FULL_VERSION=$(node -p "require('./package.json').version")
49+
MAJOR_MINOR_VERSION=$(echo "$FULL_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\.[0-9]+$/\1/')
50+
51+
echo "full-version=$FULL_VERSION" >> $GITHUB_OUTPUT
52+
echo "major-minor-version=$MAJOR_MINOR_VERSION" >> $GITHUB_OUTPUT
53+
echo "✅ 完整版本:$FULL_VERSION"
54+
echo "✅ 主版本:$MAJOR_MINOR_VERSION"
55+
56+
- name: Set up QEMU
57+
uses: docker/setup-qemu-action@v4
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v4
61+
62+
- name: Log in to the Container registry
63+
uses: docker/login-action@v4
64+
with:
65+
registry: ${{ env.REGISTRY }}
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Extract metadata (tags, labels) for Docker
70+
id: meta
71+
uses: docker/metadata-action@v6
72+
with:
73+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
74+
tags: |
75+
type=raw,value=latest,enable={{is_default_branch}}
76+
type=ref,event=branch
77+
type=ref,event=pr
78+
type=raw,value=${{ steps.extract-version.outputs.full-version }}
79+
type=raw,value=${{ steps.extract-version.outputs.major-minor-version }}
80+
81+
- name: Build and push Docker image
82+
id: build-and-push
83+
uses: docker/build-push-action@v7
84+
with:
85+
context: .
86+
push: ${{ github.event_name != 'pull_request' }}
87+
tags: ${{ steps.meta.outputs.tags }}
88+
labels: ${{ steps.meta.outputs.labels }}
89+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/riscv64,linux/s390x
90+
cache-from: type=gha
91+
cache-to: type=gha,mode=max

.github/workflows/deploy.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ jobs:
1616

1717
- name: Setup Node
1818
uses: actions/setup-node@v4
19-
20-
- name: Install pnpm
21-
uses: pnpm/action-setup@v4
2219
with:
23-
version: latest
20+
node-version: 22
21+
cache: 'npm'
2422

2523
- name: Install dependencies
26-
run: pnpm install
24+
run: npm install
2725

2826
- name: Build project
29-
run: pnpm run build
27+
run: npm run build
3028

3129
- name: Upload production-ready build files
3230
uses: actions/upload-artifact@v4
@@ -51,4 +49,4 @@ jobs:
5149
uses: peaceiris/actions-gh-pages@v3
5250
with:
5351
github_token: ${{ secrets.GITHUB_TOKEN }}
54-
publish_dir: ./dist
52+
publish_dir: ./dist

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pnpm-debug.log*
88
lerna-debug.log*
99

1010
node_modules
11+
dist
1112
dist-ssr
1213
*.local
1314

Caddyfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Caddyfile
2+
:3001 {
3+
root * ./dist
4+
file_server
5+
6+
route {
7+
try_files {path} /index.html
8+
}
9+
10+
encode gzip zstd
11+
}

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM caddy:2.11.3-alpine
2+
3+
WORKDIR /app
4+
COPY dist/ .
5+
COPY Caddyfile ./Caddyfile
6+
7+
CMD ["caddy", "run"]

deploy.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Docker 部署
2+
3+
```bash
4+
npm install && npm run build # 如果运行过,则跳过此步骤
5+
docker build -t another-graph-editor .
6+
```

edgeone.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "another-graph-editor",
3+
"buildCommand": "pnpm run build",
4+
"installCommand": "pnpm install",
5+
"outputDirectory": "./dist"
6+
}

0 commit comments

Comments
 (0)