Skip to content

Commit d0c6f7c

Browse files
authored
[frontend] feat: add quick dev frontend (#521)
1 parent dc85584 commit d0c6f7c

File tree

4 files changed

+83
-12
lines changed

4 files changed

+83
-12
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,27 @@ bash docker/dev-app-builder.sh
7373
浏览器打开 http://localhost:8001 测试
7474

7575
## 前端快速开发测试
76-
TODO
76+
本章节给出快速启动之后,本地快速开发测试前端的方法。
77+
78+
### 1. 编译代码
79+
1. 全量编译前端(1 minutes 10 seconds)
80+
编写代码,在项目根目录下,执行以下命令编译:
81+
```shell
82+
cd frontend
83+
npm install --legacy-peer-deps --force --registry=https://registry.npmmirror.com
84+
npm run build:prod
85+
```
86+
87+
### 2. 一键部署修改
88+
在项目根目录下,执行以下命令快速部署(18 seconds):
89+
```shell
90+
cd ..
91+
bash docker/dev-frontend.sh
92+
```
93+
94+
### 3. 测试
95+
浏览器打开 http://localhost:8001 测试
96+
7797

7898
## 源码编译启动
7999

docker/dev-app-builder.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ echo "=== Cleaning up temporary container ==="
5555
docker stop app-builder-tmp
5656
docker rm app-builder-tmp
5757

58-
echo "=== Updating docker-compose configuration ==="
59-
# Create docker-compose configuration for development
60-
cp docker-compose.yml docker-compose.dev.yml
61-
if [[ "$(uname -s)" == "Darwin" ]]; then
62-
sed -i '.bak' "s/app-builder:\${VERSION}/app-builder:dev-latest/g" docker-compose.dev.yml
63-
rm -f docker-compose.dev.yml.bak
64-
else
65-
sed -i "s/app-builder:\${VERSION}/app-builder:dev-latest/g" docker-compose.dev.yml
66-
fi
67-
6858
echo "=== Restarting services ==="
6959
docker-compose -f docker-compose.dev.yml -p app-platform up -d app-builder
7060

docker/dev-frontend.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
export WORKSPACE=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
5+
BUILD_DIR="${WORKSPACE}/../frontend/build/"
6+
7+
cd ${WORKSPACE}
8+
source .env
9+
10+
# Generate development version tag
11+
BASE_VERSION=${VERSION}
12+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
13+
GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
14+
DEV_VERSION="${BASE_VERSION}-dev-${TIMESTAMP}-${GIT_COMMIT}"
15+
16+
echo "=== Version Information ==="
17+
echo "Base Version: ${BASE_VERSION}"
18+
echo "Development Version: ${DEV_VERSION}"
19+
echo "Git Commit: ${GIT_COMMIT}"
20+
21+
# Check local build artifacts
22+
if [ ! -d "$BUILD_DIR" ] || [ -z "$(ls -A "$BUILD_DIR" 2>/dev/null)" ]; then
23+
echo "Error: plugins directory is empty or does not exist: $BUILD_DIR"
24+
exit 1
25+
fi
26+
27+
echo "=== Stopping web service ==="
28+
docker-compose stop web
29+
30+
echo "=== Creating development version image ==="
31+
# Use stable version as base
32+
docker run -d --name web-tmp --entrypoint sleep ${REPO}/jade-web:${BASE_VERSION} infinity
33+
34+
# Copy files
35+
echo "Copying frontend files..."
36+
docker exec web-tmp rm -rf //usr//share//nginx//html
37+
docker exec web-tmp mkdir -p //usr//share//nginx//html
38+
docker cp "$BUILD_DIR"/. web-tmp:/usr/share/nginx/html/
39+
40+
# Commit as development version
41+
echo "Committing development version image: ${DEV_VERSION}"
42+
docker commit --change='ENTRYPOINT ["/init.sh"]' web-tmp ${REPO}/jade-web:${DEV_VERSION}
43+
44+
# Create development tag (for docker-compose convenience)
45+
docker tag ${REPO}/jade-web:${DEV_VERSION} ${REPO}/jade-web:dev-latest
46+
47+
echo "=== Cleaning up temporary container ==="
48+
docker stop web-tmp
49+
docker rm web-tmp
50+
51+
echo "=== Restarting services ==="
52+
docker-compose -f docker-compose.dev.yml -p app-platform up -d web
53+
54+
echo ""
55+
echo "=== Completed! ==="
56+
echo "Development version deployed: ${DEV_VERSION}"
57+
echo "Current tag in use: dev-latest"
58+
echo "Service URL: http://localhost:8001"
59+
echo ""
60+
echo "=== Version Management Commands ==="
61+
echo "View all versions: docker images ${REPO}/jade-web"

docker/docker-compose.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ services:
174174
web:
175175
container_name: web
176176
hostname: web
177-
image: ${REPO}/jade-web:${VERSION}
177+
image: ${REPO}/jade-web:dev-latest
178178
depends_on:
179179
app-builder:
180180
condition: service_healthy

0 commit comments

Comments
 (0)