Skip to content

Instantly share code, notes, and snippets.

@steveliles
Created January 10, 2018 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveliles/71f07eefce071e5f43ffeec3fd863941 to your computer and use it in GitHub Desktop.
Save steveliles/71f07eefce071e5f43ffeec3fd863941 to your computer and use it in GitHub Desktop.
image: my-docker-hub/my-pipeline-container
options:
docker: true
pipelines:
branches:
production:
- step:
caches:
- node
script:
# build and test the app
- npm install
- npm test
# build docker image containing the app (see ./Dockerfile)
- export IMAGE_NAME=$AWS_REGISTRY_URL/$BITBUCKET_REPO_SLUG:$BITBUCKET_COMMIT
- docker build -t $IMAGE_NAME .
- eval $(~/bin/aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email | sed 's|https://||')
- docker push $IMAGE_NAME
# register the end-user-api ECS task definition and capture the version
- export TASK_VERSION=$(~/bin/aws ecs register-task-definition --family $BITBUCKET_REPO --container-definitions "[{\"name\":\"$BITBUCKET_REPO\",\"image\":\"$IMAGE_NAME\",\"memory\":250,\"essential\":true,\"portMappings\":[{\"containerPort\":3001,\"hostPort\":3001,\"protocol\":\"tcp\"}]}]" | jq --raw-output '.taskDefinition.revision')
- echo "Registered $BITBUCKET_REPO ECS Task Definition " $TASK_VERSION
# Update the end-user-api ECS service to use the updated Task version
- ~/bin/aws ecs update-service --cluster $BITBUCKET_BRANCH --service $BITBUCKET_REPO --task-definition $BITBUCKET_REPO:$TASK_VERSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment