Created
July 1, 2021 14:04
-
-
Save tumainimosha/bfad223e9057472cffbea2877ce9d944 to your computer and use it in GitHub Desktop.
This file contains 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
# ----- | |
# 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