Skip to content

Instantly share code, notes, and snippets.

@tumainimosha
Created July 1, 2021 14:04
Show Gist options
  • Save tumainimosha/bfad223e9057472cffbea2877ce9d944 to your computer and use it in GitHub Desktop.
Save tumainimosha/bfad223e9057472cffbea2877ce9d944 to your computer and use it in GitHub Desktop.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
# We are using chybie/node-aws-cli image which contains npm and aws-cli tools
#
# Also you need to specify AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in
# pipeline environment variables for push to s3 to work
#
# Pipeline is configured to run only on master branch, but you can configure
# additional branches if required
# Node Image for docker on which code will execute
image: node:latest
# This is the stages / task to perfom in jobs
stages:
- build
- deploy
# Job One for making build
build_dev:
stage: build
variables:
NODE_ENV: 'development'
# type: build
script:
- npm set progress=false
- npm ci --cache .npm --prefer-offline
- npm run build
only: ['master']
tags:
- docker
# caching for reuse
cache:
key: ${CI_PROJECT_ID}
paths:
- .npm/
- node_modules/
artifacts:
paths:
- dist/
expire_in: 1 hour
# Job Two for deploy build to EC2
deploy_dev:
stage: deploy
# type: deploy
script:
- npm install
- rm -r /home/deploy/app-api/dist/
- rm -r /home/deploy/app-api/node_modules/
- cp -r ./dist/ /home/deploy/app-api/dist/
- cp -r ./node_modules/ /home/deploy/app-api/node_modules/
- pm2 restart APP-API
only: ['master']
tags:
- node-staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment