Skip to content

Instantly share code, notes, and snippets.

@nadyshalaby
Last active June 26, 2023 08:02
Show Gist options
  • Save nadyshalaby/756506dba7e4f677de3524204c387a82 to your computer and use it in GitHub Desktop.
Save nadyshalaby/756506dba7e4f677de3524204c387a82 to your computer and use it in GitHub Desktop.
How to deploy a NestJs Application on GCP Compute Engine
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'
#!/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)
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