-
Notifications
You must be signed in to change notification settings - Fork 46
chore: P2 deploy ./api stage to zcluster
#655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
34a2ee9
deploy ./api to stage
ZibanPirate 6052da6
update api deployment job in stage cd action
ZibanPirate df38c56
deploy once both web-server and api images are built and pushed
ZibanPirate 88e6368
fix: remove redundant tag from docker image and push commands
ZibanPirate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| FROM --platform=linux/amd64 node:22 | ||
|
|
||
| WORKDIR /usr/src/repo | ||
|
|
||
| COPY ./package.json ./package.json | ||
|
|
||
| # AUTO_GEN | ||
| COPY ./api/dist ./api/dist | ||
| COPY ./api/package.json ./api/package.json | ||
| COPY ./api/db ./api/db | ||
| COPY ./packages/tooling/package.json ./packages/tooling/package.json | ||
| COPY ./data/dist ./data/dist | ||
| COPY ./data/package.json ./data/package.json | ||
| COPY ./data/models ./data/models | ||
| COPY ./packages/models/dist ./packages/models/dist | ||
| COPY ./packages/models/package.json ./packages/models/package.json | ||
| COPY ./packages/utils/dist ./packages/utils/dist | ||
| COPY ./packages/utils/package.json ./packages/utils/package.json | ||
| # AUTO_GEN_END | ||
|
|
||
| RUN npm install --omit=dev [email protected]/api | ||
|
|
||
| ENV PORT=80 | ||
| WORKDIR /usr/src/repo/api | ||
| CMD [ "npm", "run", "start" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,10 @@ struct Args { | |
| /// Environment to deploy to | ||
| #[arg(short, long, value_enum)] | ||
| env: Env, | ||
|
|
||
| /// Clean build | ||
| #[arg(short, long, default_value_t = false)] | ||
| clean: bool, | ||
| } | ||
|
|
||
| fn main() { | ||
|
|
@@ -32,17 +36,26 @@ fn main() { | |
| println!("Ensuring docker is running ..."); | ||
| cli_run::cli_run("docker", vec!["ps"]); | ||
|
|
||
| println!("Building ./web-server ..."); | ||
| cli_run::cli_run("npm", vec!["run", "clean"]); | ||
| cli_run::cli_run("npm", vec!["run", "bundle", "[email protected]/web"]); | ||
| cli_run::cli_run("npm", vec!["run", "pre-deploy", "[email protected]/web"]); | ||
| cli_run::cli_run("npm", vec!["run", "build", "[email protected]/web-server"]); | ||
| if args.clean { | ||
| println!("clean..."); | ||
| cli_run::cli_run("npm", vec!["run", "clean"]); | ||
| } | ||
|
|
||
| println!("Build..."); | ||
| cli_run::cli_run("npm", vec!["run", "build"]); | ||
|
|
||
| println!("Writing ./web-server deps into Dockerfile..."); | ||
| println!("Preparing ./web-server ..."); | ||
| cli_run::cli_run("npm", vec!["run", "bundle:alone", "[email protected]/web"]); | ||
| cli_run::cli_run("npm", vec!["run", "pre-deploy", "[email protected]/web"]); | ||
| cli_run::cli_run("npm", vec!["run", "prepare-dockerfile", "[email protected]/web-server"]); | ||
|
|
||
| println!("Building docker image ..."); | ||
| println!("Preparing ./api ..."); | ||
| cli_run::cli_run("npm", vec!["run", "prepare-dockerfile", "[email protected]/api"]); | ||
|
|
||
|
|
||
| let env_str = format!("{:?}", env).to_lowercase(); | ||
|
|
||
| println!("Building ./web-server docker image ..."); | ||
| cli_run::cli_run( | ||
| "docker", | ||
| vec![ | ||
|
|
@@ -56,6 +69,21 @@ fn main() { | |
| ], | ||
| ); | ||
|
|
||
| println!("Building ./api docker image ..."); | ||
| cli_run::cli_run( | ||
| "docker", | ||
| vec![ | ||
| "buildx", | ||
| "build", | ||
| "-f", | ||
| "api.Dockerfile", | ||
| ".", | ||
| "-t", | ||
| &format!("ghcr.io/dzcode-io/api-dot-{}-dot-dzcode-dot-io-server:latest", env_str), | ||
| ], | ||
| ); | ||
|
|
||
|
|
||
| println!("Logging in to GitHub Container Registry ..."); | ||
| let gh_token = std::env::var("DOCKER_REGISTRY_PASSWORD") | ||
| .expect("DOCKER_REGISTRY_PASSWORD environment variable not set"); | ||
|
|
@@ -76,6 +104,10 @@ fn main() { | |
| "docker", | ||
| vec!["push", &format!("ghcr.io/dzcode-io/{}-dot-dzcode-dot-io-server:latest", env_str)], | ||
| ); | ||
| cli_run::cli_run( | ||
| "docker", | ||
| vec!["push", &format!("ghcr.io/dzcode-io/api-dot-{}-dot-dzcode-dot-io-server:latest", env_str)], | ||
| ); | ||
|
|
||
| println!("Deploying to zcluster ..."); | ||
| cli_run::cli_run( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ COPY ./web-server/dist ./web-server/dist | |
| COPY ./web-server/package.json ./web-server/package.json | ||
| COPY ./api/dist ./api/dist | ||
| COPY ./api/package.json ./api/package.json | ||
| COPY ./api/db ./api/db | ||
| COPY ./packages/models/dist ./packages/models/dist | ||
| COPY ./packages/models/package.json ./packages/models/package.json | ||
| COPY ./packages/utils/dist ./packages/utils/dist | ||
|
|
@@ -19,9 +20,10 @@ COPY ./web/package.json ./web/package.json | |
| COPY ./packages/tooling/package.json ./packages/tooling/package.json | ||
| COPY ./data/dist ./data/dist | ||
| COPY ./data/package.json ./data/package.json | ||
| COPY ./data/models ./data/models | ||
| # AUTO_GEN_END | ||
|
|
||
| RUN npm install --install-strategy=nested --omit=dev [email protected]/web-server | ||
| RUN npm install --omit=dev [email protected]/web-server | ||
|
|
||
| ENV PORT=80 | ||
| WORKDIR /usr/src/repo/web-server | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ | |
| "lint:prettier": "prettier --config ../packages/tooling/.prettierrc --ignore-path ../packages/tooling/.prettierignore --log-level warn", | ||
| "lint:ts-prune": "tsx ../packages/tooling/setup-ts-prune.ts && ts-prune --error", | ||
| "lint:tsc": "tsc --noEmit", | ||
| "prepare-dockerfile": "tsx ../packages/tooling/write-dockerfile.ts", | ||
| "prepare-dockerfile": "tsx ../packages/tooling/write-dockerfile.ts @dzcode.io/web-server", | ||
| "prepare-web": "lerna run bundle [email protected]/web --include-dependencies --stream && lerna run pre-deploy [email protected]/web --include-dependencies --stream", | ||
| "start": "node dist/app/index.js", | ||
| "start:dev": "npm run prepare-web && tsx ../packages/tooling/nodemon.ts \"@dzcode.io/web-server\" && npm run start:nodemon", | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not well formatted it seems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup rust fmt doesn't yet work with caro-script, will format it in #656