Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ef43ce1d
Commit
ef43ce1d
authored
Mar 16, 2020
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '207962-deploy-ecs' into 'master'
Add template to deploy to ECS See merge request gitlab-org/gitlab!26371
parents
e016d433
c34d4b4e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
0 deletions
+99
-0
changelogs/unreleased/207962-deploy-ecs.yml
changelogs/unreleased/207962-deploy-ecs.yml
+5
-0
doc/ci/cloud_deployment/index.md
doc/ci/cloud_deployment/index.md
+58
-0
doc/ci/img/ecs_dashboard_v12_9.png
doc/ci/img/ecs_dashboard_v12_9.png
+0
-0
lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
+36
-0
No files found.
changelogs/unreleased/207962-deploy-ecs.yml
0 → 100644
View file @
ef43ce1d
---
title
:
Add CI template to deploy to ECS
merge_request
:
26371
author
:
type
:
added
doc/ci/cloud_deployment/index.md
View file @
ef43ce1d
...
@@ -61,3 +61,61 @@ To do so, please make sure to [push your image into your ECR
...
@@ -61,3 +61,61 @@ To do so, please make sure to [push your image into your ECR
repository
](
https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html
)
repository
](
https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html
)
before referencing it in your
`.gitlab-ci.yml`
file and replace the
`image`
before referencing it in your
`.gitlab-ci.yml`
file and replace the
`image`
path to point to your ECR.
path to point to your ECR.
### Deploy your application to AWS Elastic Container Service (ECS)
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/207962) in GitLab 12.9.
GitLab provides a series of
[
CI templates that you can include in your project
](
../yaml/README.md#include
)
.
To automate deployments of your application to your
[
Amazon Elastic Container Service
](
https://aws.amazon.com/ecs/
)
(
AWS
ECS)
cluster, you can
`include`
the
`Deploy-ECS.gitlab-ci.yml`
template in your
`.gitlab-ci.yml`
file.
Before getting started with this process, you need a cluster on AWS ECS, as well as related
components, like an ECS service, ECS task definition, a database on AWS RDS, etc.
[
Read more about AWS ECS
](
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html
)
.
After you're all set up on AWS ECS, follow these steps:
1.
Make sure your AWS credentials are set up as environment variables for your
project. You can follow
[
the steps above
](
#aws
)
to complete this setup.
1.
Add these variables to your project's
`.gitlab-ci.yml`
file:
```
yaml
variables
:
CI_AWS_ECS_CLUSTER
:
my-cluster
CI_AWS_ECS_SERVICE
:
my-service
CI_AWS_ECS_TASK_DEFINITION
:
my-task-definition
```
Three variables are defined in this snippet:
-
`CI_AWS_ECS_CLUSTER`
: The name of your AWS ECS cluster that you're
targeting for your deployments.
-
`CI_AWS_ECS_SERVICE`
: The name of the targeted service tied to
your AWS ECS cluster.
-
`CI_AWS_ECS_TASK_DEFINITION`
: The name of the task definition tied
to the service mentioned above.
You can find these names after selecting the targeted cluster on your
[
AWS ECS dashboard
](
https://console.aws.amazon.com/ecs/home
)
:
!
[
AWS ECS dashboard
](
../img/ecs_dashboard_v12_9.png
)
1.
Include this template in
`.gitlab-ci.yml`
:
```
yaml
include
:
-
template
:
Deploy-ECS.gitlab-ci.yml
```
The
`Deploy-ECS`
template ships with GitLab and is available
[
on
GitLab.com
](
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
)
.
1.
Commit and push your updated
`.gitlab-ci.yml`
to your project's repository, and you're done!
Your application Docker image will be rebuilt and pushed to the GitLab registry.
Then the targeted task definition will be updated with the location of the new
Docker image, and a new revision will be created in ECS as result.
Finally, your AWS ECS service will be updated with the new revision of the
task definition, making the cluster pull the newest version of your
application.
doc/ci/img/ecs_dashboard_v12_9.png
0 → 100644
View file @
ef43ce1d
107 KB
lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
0 → 100644
View file @
ef43ce1d
stages
:
-
build
-
test
-
review
-
deploy
-
production
include
:
-
template
:
Jobs/Build.gitlab-ci.yml
.deploy_to_ecs
:
image
:
registry.gitlab.com/gitlab-org/cloud-deploy:latest
script
:
-
ecs update-task-definition
review
:
extends
:
.deploy_to_ecs
stage
:
review
environment
:
name
:
review/$CI_COMMIT_REF_NAME
only
:
refs
:
-
branches
-
tags
except
:
refs
:
-
master
production
:
extends
:
.deploy_to_ecs
stage
:
production
environment
:
name
:
production
only
:
refs
:
-
master
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment