Skip to content

Commit a7a01a7

Browse files
committed
setup ./web-server CD
1 parent 8cb7473 commit a7a01a7

File tree

5 files changed

+60
-6
lines changed

5 files changed

+60
-6
lines changed

.github/workflows/cd.deploy.stg.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,56 @@ jobs:
4747
run: cd ./api && npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
4848
- name: "Deploy"
4949
run: cd ./api && npm run deploy:stg
50+
51+
deploy-web-server:
52+
needs: build
53+
runs-on: ubuntu-latest
54+
env:
55+
CI: true
56+
STAGE: staging
57+
DEPLOY_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || format('stg-0.0.0-{0}-{1}-{2}', github.ref_name, github.run_number, github.run_attempt) }}
58+
59+
steps:
60+
- name: "Git"
61+
uses: actions/checkout@v4
62+
- name: "Nodejs"
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: "20"
66+
cache: "npm"
67+
- run: npm ci
68+
- name: Download artifact
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: build output (ubuntu-latest, 20)
72+
73+
- name: "Generate Bundle info"
74+
run: npm run generate:bundle-info $DEPLOY_VERSION stage
75+
76+
- name: "Sentry Release"
77+
# todo-zm: remove sentry entirely
78+
run: cd ./web && npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
79+
80+
- name: "Bundle ./web for deployment"
81+
run: |
82+
cd ./web
83+
npm run bundle
84+
npm run pre-deploy
85+
86+
- name: "Write ./web-server deps into Dockerfile..."
87+
run: |
88+
cd ./web-server
89+
npm run prepare-dockerfile
90+
91+
- name: Build docker image
92+
run: |
93+
docker build ./web-server.Dockerfile -t ghcr.io/dzcode-io/stage-dot-dzcode-dot-io-server:latest
94+
env:
95+
DOCKER_BUILDKIT: 1
96+
97+
- name: Push docker image
98+
run: |
99+
echo $CR_PAT | docker login ghcr.io -u dzcode-io --password-stdin
100+
docker push ghcr.io/dzcode-io/stage-dot-dzcode-dot-io-server:latest
101+
env:
102+
CR_PAT: ${{ secrets.CR_PAT }}

packages/tooling/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ nodemon.json
3030
*.patch
3131
*.sql
3232
*.conf
33+
*.Dockerfile

packages/tooling/write-dockerfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, writeFileSync } from "fs";
33
import { join } from "path";
44

55
const workspaceRoot = join(__dirname, "../..");
6-
const dockerFilePath = join(workspaceRoot, "Dockerfile");
6+
const dockerFilePath = join(workspaceRoot, "web-server.Dockerfile");
77

88
console.log(`writing ${dockerFilePath} ...`);
99

scripts/deploy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn main() {
4747
"docker",
4848
vec![
4949
"build",
50-
".",
50+
"./web-server.Dockerfile",
5151
"-t",
5252
&format!("ghcr.io/dzcode-io/{}-dot-dzcode-dot-io-server:latest", env_str),
5353
],

Dockerfile renamed to web-server.Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ COPY ./package.json ./package.json
77
# AUTO_GEN
88
COPY ./web-server/dist ./web-server/dist
99
COPY ./web-server/package.json ./web-server/package.json
10-
COPY ./packages/utils/dist ./packages/utils/dist
11-
COPY ./packages/utils/package.json ./packages/utils/package.json
12-
COPY ./packages/models/dist ./packages/models/dist
13-
COPY ./packages/models/package.json ./packages/models/package.json
1410
COPY ./api/dist ./api/dist
1511
COPY ./api/package.json ./api/package.json
12+
COPY ./packages/models/dist ./packages/models/dist
13+
COPY ./packages/models/package.json ./packages/models/package.json
14+
COPY ./packages/utils/dist ./packages/utils/dist
15+
COPY ./packages/utils/package.json ./packages/utils/package.json
1616
COPY ./web/dist ./web/dist
1717
COPY ./web/bundle ./web/bundle
1818
COPY ./web/package.json ./web/package.json

0 commit comments

Comments
 (0)