Last active
June 26, 2023 08:02
-
-
Save nadyshalaby/756506dba7e4f677de3524204c387a82 to your computer and use it in GitHub Desktop.
How to deploy a NestJs Application on GCP Compute Engine
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
image: atlassian/default-image:3 | |
pipelines: | |
branches: | |
develop: | |
- step: | |
name: Deploy to GCP | |
caches: | |
- docker | |
script: | |
- pipe: atlassian/ssh-run:0.4.2 | |
variables: | |
SSH_USER: $GCP_SSH_USER | |
SERVER: $GCP_SSH_SERVER | |
COMMAND: 'sh ~/${BITBUCKET_REPO_SLUG}/deploy.sh ${BITBUCKET_BRANCH}' | |
MODE: 'command' | |
DEBUG: 'true' |
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
#!/usr/bin/sh | |
export PATH="$PATH:$HOME/.nvm/versions/node/v19.9.0/bin" | |
cd "$HOME/<project-path>" || exit | |
git fetch --all | |
git reset --hard origin/$1 | |
git pull origin $1 | |
npm install --silent && npm run build --silent | |
# Make sure that webserver reloaded after each project change (e.g. pm2) |
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
module.exports = { | |
apps: [ | |
{ | |
name: "app", | |
script: "npm run start:prod", | |
watch: true // Watch the files and restart the app if they change | |
} | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment