Public | Automated Build

Last pushed: 10 months ago
Short Description
Simple image to use in Bitbucket Pipelines
Full Description

pipeline npm

This is a Docker image that includes awscli for use in a Bitbucket Pipeline that deploys a site to s3.

Supported tags and respective Dockerfile links

Usage

Your bitbucket-pipelines.yml file might look something like this:

image: commonmedia/pipeline-npm:1.1.0

pipelines:
  default:
    - step:
        script:
          - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
  branches:
    master:
      - step:
          script:
            - echo "This script only runs on commits to the master branch."
            - npm install
            - npm run build_prod
            - aws s3 mv s3://CHANGE/ s3://CHANGE/releases/$(date '+%Y-%d-%m-%H%M%S') --recursive --exclude "releases/*"
            - aws s3 sync ./dist s3://CHANGE/
            - aws configure set preview.cloudfront true
            - aws cloudfront create-invalidation --distribution-id CHANGE --paths /index.html
    staging:
      - step:
          script:
            - echo "This script only runs on commits to the staging branch."
            - npm install
            - npm run build_staging
            - aws s3 mv s3://CHANGE/ s3://CHANGE/releases/$(date '+%Y-%d-%m-%H%M%S') --recursive --exclude "releases/*"
            - aws s3 sync ./dist s3://CHANGE/
            - aws configure set preview.cloudfront true
            - aws cloudfront create-invalidation --distribution-id CHANGE --paths /index.html

The process above is as follows:

  • Installs required npm packages
  • Runs the build process
  • Moves the existing files in the s3 bucket to a dated (YYYY-MM-DD-HHMMSS) folder
  • Sends the built site to the s3 bucket
  • Invalidates the CloudFront cache
Docker Pull Command
Owner
commonmedia
Source Repository

Comments (0)