Skip to content

Instantly share code, notes, and snippets.

@msfidelis
Created June 26, 2019 15:48
Show Gist options
  • Save msfidelis/b6e2cf4eef06367c685fc2453530881d to your computer and use it in GitHub Desktop.
Save msfidelis/b6e2cf4eef06367c685fc2453530881d to your computer and use it in GitHub Desktop.
version: 0.2
phases:
pre_build:
commands:
- pip install awscli --upgrade --user
- echo `aws --version`
- echo Installing Node 8
- curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
- apt-get install -y nodejs
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --region ${region} --no-include-email)
- REPOSITORY_URI=${repository_url}
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- echo Entered the pre_build phase...
- npm install
build:
commands:
- echo Build started on `date`
- echo Starting Unit Tests
- npm run unit-test
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- printf '[{"name":"${container_name}","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
files: imagedefinitions.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment