Skip to content

Instantly share code, notes, and snippets.

@nwellis-opi

nwellis-opi/.gitlab-ci.yml

Last active Jan 30, 2020
Embed
What would you like to do?
AWS Fargate GitLab Pipeline
stages:
- build
- deploy
variables:
BASE_REPOSITORY_URL: 936832894876.dkr.ecr.us-east-2.amazonaws.com/slackbot/feedback-bot
.aws_setup:
image: docker:latest
services:
- docker:dind
before_script:
- apk add --no-cache curl jq python py-pip
- pip install awscli
- $(aws ecr get-login --no-include-email --region $AWS_REGION)
tags:
- docker
# BUILD
.build_job:
extends: .aws_setup
stage: build
script:
- docker build -t $REPOSITORY_URL .
- docker push $REPOSITORY_URL
build_dev:
extends: .build_job
variables:
REPOSITORY_URL: ${BASE_REPOSITORY_URL}:dev
environment:
name: development
only:
- develop
build_prod:
extends: .build_job
variables:
REPOSITORY_URL: ${BASE_REPOSITORY_URL}
environment:
name: production
only:
- master
# DEPLOY
.deploy_job:
extends: .aws_setup
stage: deploy
script:
- aws ecs register-task-definition
--family $TASK_DEF_NAME
--requires-compatibilities FARGATE
--cli-input-json $TASK_DEF_FILE
--region $AWS_REGION
- aws ecs update-service
--cluster $ECS_CLUSTER
--service feedback-bot
--task-definition $TASK_DEF_NAME
--region $AWS_REGION
deploy_dev:
extends: .deploy_job
variables:
ECS_CLUSTER: slackbot-dev
TASK_DEF_NAME: feedback-bot-dev
TASK_DEF_FILE: file://aws/task-def-dev.json
environment:
name: development
only:
- develop
deploy_prod:
extends: .deploy_job
variables:
ECS_CLUSTER: slackbot-prod
TASK_DEF_NAME: feedback-bot-prod
TASK_DEF_FILE: file://aws/task-def-prod.json
environment:
name: production
when: manual
allow_failure: false
only:
- master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.