Created
January 10, 2018 16:59
-
-
Save steveliles/71f07eefce071e5f43ffeec3fd863941 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
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