Skip to content

Commit 3bad363

Browse files
committed
ci: 支持webpack-vue3项目部署
fix #74 chore: 更新 lock 文件 chore: version packages build: dockerfile缺失webpack-vue3目录 chore: 更新changesets
1 parent 0b2e86d commit 3bad363

File tree

133 files changed

+291
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+291
-191
lines changed

.changeset/fresh-laws-accept.md

Lines changed: 6 additions & 0 deletions

.github/workflows/frontend.yml renamed to .github/workflows/vite-vue3.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: frontend_cicd
1+
name: vite-vue3-cicd
22

33
on:
44
push:
@@ -31,8 +31,8 @@ jobs:
3131
run: |
3232
echo "${{env.IMAGE_VERSION}}"
3333
docker login --username=${{secrets.DOCKER_USERNAME}} --password=${{secrets.DOCKER_PASSWORD}} ${{secrets.DOCKER_REGISTRY}}
34-
docker build --target frontend -t ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/${{secrets.DOCKER_FRONTEND_REPOSITORY}}:${{env.IMAGE_VERSION}} .
35-
docker push ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/${{secrets.DOCKER_FRONTEND_REPOSITORY}}:${{env.IMAGE_VERSION}}
34+
docker build --target vite-vue3-frontend -t ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-vite-vue3:${{env.IMAGE_VERSION}} .
35+
docker push ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-vite-vue3:${{env.IMAGE_VERSION}}
3636
3737
deploy:
3838
needs: [extract, build]
@@ -62,9 +62,9 @@ jobs:
6262
cat >>~/remote.sh <<END
6363
docker ps
6464
docker login --username=${{secrets.DOCKER_USERNAME}} --password=${{secrets.DOCKER_PASSWORD}} ${{secrets.DOCKER_REGISTRY}}
65-
docker pull ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/${{secrets.DOCKER_FRONTEND_REPOSITORY}}:${{env.IMAGE_VERSION}}
65+
docker pull ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-vite-vue3:${{env.IMAGE_VERSION}}
6666
cd ${{secrets.PROJECT_DIR}}
67-
sed -i 's/^FRONTEND_VERSION=.*/FRONTEND_VERSION=${{env.IMAGE_VERSION}}/' .env.docker.local
67+
sed -i 's/^VITE_VUE3_VERSION=.*/VITE_VUE3_VERSION=${{env.IMAGE_VERSION}}/' .env.docker.local
6868
docker compose --env-file .env.docker.local up -d
6969
echo "Done"
7070
END

.github/workflows/webpack-vue3.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: webpack-vue3-cicd
2+
3+
on:
4+
push:
5+
tags:
6+
- 'webpack-vue3@*'
7+
8+
env:
9+
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
10+
11+
jobs:
12+
extract:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.extract_version.outputs.version }}
16+
steps:
17+
- id: extract_version
18+
run: |
19+
echo "version=$(echo ${{ github.ref_name }} | sed 's/webpack-vue3@//')" >> $GITHUB_OUTPUT
20+
21+
build:
22+
needs: extract
23+
runs-on: ubuntu-latest
24+
env:
25+
IMAGE_VERSION: ${{ needs.extract.outputs.version }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Build & Push Image
31+
run: |
32+
echo "${{env.IMAGE_VERSION}}"
33+
docker login --username=${{secrets.DOCKER_USERNAME}} --password=${{secrets.DOCKER_PASSWORD}} ${{secrets.DOCKER_REGISTRY}}
34+
docker build --target webpack-vue3-frontend -t ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-webpack-vue3:${{env.IMAGE_VERSION}} .
35+
docker push ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-webpack-vue3:${{env.IMAGE_VERSION}}
36+
37+
deploy:
38+
needs: [extract, build]
39+
runs-on: ubuntu-latest
40+
env:
41+
IMAGE_VERSION: ${{ needs.extract.outputs.version }}
42+
steps:
43+
- name: SSH Auth && Deploy Image
44+
run: |
45+
ssh -V
46+
47+
mkdir -p ~/.ssh
48+
49+
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
50+
51+
chmod 600 ~/.ssh/id_rsa
52+
53+
cat >>~/.ssh/config <<END
54+
Host remote
55+
HostName ${{secrets.SSH_HOST}}
56+
Port 22
57+
User ${{secrets.SSH_USERNAME}}
58+
IdentityFile ~/.ssh/id_rsa
59+
StrictHostKeyChecking no
60+
END
61+
62+
cat >>~/remote.sh <<END
63+
docker ps
64+
docker login --username=${{secrets.DOCKER_USERNAME}} --password=${{secrets.DOCKER_PASSWORD}} ${{secrets.DOCKER_REGISTRY}}
65+
docker pull ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-webpack-vue3:${{env.IMAGE_VERSION}}
66+
cd ${{secrets.PROJECT_DIR}}
67+
sed -i 's/^WEBPACK_VUE3_VERSION=.*/WEBPACK_VUE3_VERSION=${{env.IMAGE_VERSION}}/' .env.docker.local
68+
docker compose --env-file .env.docker.local up -d
69+
echo "Done"
70+
END
71+
72+
ssh remote < ~/remote.sh

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ dist
44
.eslintcache
55
.stylelintcache
66

7-
# backend
8-
app/backend/src/config/dev.env.js
9-
app/backend/src/config/env.js
10-
app/backend/src/config/prod.env.js
11-
app/backend/deploy.config.js
12-
137
# local env files
148
.env.local
159
.env.*.local

.lintstagedrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"app/frontend/src/**/*.{js,mjs,jsx,ts,tsx,vue}": "pnpm --filter frontend lint-fix",
3-
"app/frontend/src/**/*.{css,less,scss,vue}": "pnpm --filter frontend lint-style-fix",
2+
"app/webpack-vue3/src/**/*.{js,mjs,jsx,ts,tsx,vue}": "pnpm --filter webpack-vue3 lint-fix",
3+
"app/webpack-vue3/src/**/*.{css,less,scss,vue}": "pnpm --filter webpack-vue3 lint-style-fix",
44
"app/vite-vue3/src/**/*.{js,mjs,jsx,ts,tsx,vue}": "pnpm --filter vite-vue3 lint-fix",
55
"app/vite-vue3/src/**/*.{css,less,scss,vue}": "pnpm --filter vite-vue3 lint-style-fix",
66
"app/backend/src/**/*.js": "pnpm --filter backend lint-fix"

Dockerfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,29 @@ FROM base AS build
77
COPY . /usr/src/app
88
WORKDIR /usr/src/app
99
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
10-
RUN pnpm deploy --filter=vite-vue3 /app/frontend
10+
RUN pnpm deploy --filter=vite-vue3 /app/vite-vue3
11+
RUN pnpm deploy --filter=webpack-vue3 /app/webpack-vue3
1112
RUN pnpm deploy --filter=backend /app/backend
1213

13-
FROM base AS frontend-build
14-
COPY --from=build /app/frontend /usr/src/fullstack-blog/app/frontend
14+
FROM base AS vite-vue3-build
15+
COPY --from=build /app/vite-vue3 /usr/src/fullstack-blog/app/vite-vue3
1516
COPY tsconfig.base.json /usr/src/fullstack-blog/tsconfig.base.json
16-
WORKDIR /usr/src/fullstack-blog/app/frontend
17+
WORKDIR /usr/src/fullstack-blog/app/vite-vue3
1718
RUN pnpm build
1819

19-
FROM nginx:latest AS frontend
20-
COPY --from=frontend-build /usr/src/fullstack-blog/app/frontend/dist/ /usr/share/nginx/html
20+
FROM nginx:latest AS vite-vue3-frontend
21+
COPY --from=vite-vue3-build /usr/src/fullstack-blog/app/vite-vue3/dist/ /usr/share/nginx/html
22+
COPY nginx/default.conf.template /etc/nginx/conf.d/default.conf.template
23+
EXPOSE 80
24+
25+
FROM base AS webpack-vue3-build
26+
COPY --from=build /app/webpack-vue3 /usr/src/fullstack-blog/app/webpack-vue3
27+
COPY tsconfig.base.json /usr/src/fullstack-blog/tsconfig.base.json
28+
WORKDIR /usr/src/fullstack-blog/app/webpack-vue3
29+
RUN pnpm build
30+
31+
FROM nginx:latest AS webpack-vue3-frontend
32+
COPY --from=webpack-vue3-build /usr/src/fullstack-blog/app/webpack-vue3/dist/ /usr/share/nginx/html
2133
COPY nginx/default.conf.template /etc/nginx/conf.d/default.conf.template
2234
EXPOSE 80
2335

Dockerfile.dev

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ FROM base AS build
77
COPY . /usr/src/app
88
WORKDIR /usr/src/app
99
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
10-
RUN pnpm deploy --filter=vite-vue3 /app/frontend
10+
RUN pnpm deploy --filter=vite-vue3 /app/vite-vue3
1111
RUN pnpm deploy --filter=backend /app/backend
1212

13-
FROM base AS frontend
14-
COPY --from=build /app/frontend /usr/src/fullstack-blog/app/frontend
15-
WORKDIR /usr/src/fullstack-blog/app/frontend
13+
FROM base AS vite-vue3-frontend
14+
COPY --from=build /app/vite-vue3 /usr/src/fullstack-blog/app/vite-vue3
15+
WORKDIR /usr/src/fullstack-blog/app/vite-vue3
1616
EXPOSE 3000
1717
CMD ["pnpm", "dev"]
1818

README.md

Lines changed: 3 additions & 2 deletions

app/backend/.gitignore

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# 敏感配置信息
2-
config/dev.env.js
3-
config/env.js
4-
config/prod.env.js
5-
deploy.config.js
6-
7-
# Logs
8-
logs
9-
*.log
10-
11-
# Optional eslint cache
12-
.eslintcache
1+
# 敏感配置信息
2+
src/config/dev.env.js
3+
src/config/env.js
4+
src/config/prod.env.js
5+
deploy.config.js
6+
7+
# Logs
8+
logs
9+
*.log
10+
11+
# Optional eslint cache
12+
.eslintcache

app/frontend/public/robots.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)