ufo 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/docs/_docs/conventions.md +4 -0
- data/docs/_docs/helpers.md +1 -1
- data/docs/_docs/install.md +11 -11
- data/docs/_docs/settings.md +64 -23
- data/docs/_docs/structure.md +7 -2
- data/docs/_docs/tutorial-ufo-init.md +22 -16
- data/docs/_docs/tutorial-ufo-ship.md +19 -18
- data/docs/_docs/tutorial-ufo-ships.md +5 -5
- data/docs/_docs/tutorial-ufo-tasks-build.md +50 -63
- data/docs/_docs/ufo-destroy.md +2 -2
- data/docs/_docs/ufo-env.md +54 -0
- data/docs/_docs/ufo-init.md +7 -3
- data/docs/_docs/ufo-scale.md +2 -2
- data/docs/_docs/ufo-ship.md +8 -8
- data/docs/_docs/ufo-ships.md +4 -4
- data/docs/_docs/ufo-tasks-build.md +42 -26
- data/docs/_docs/ufo-tasks-register.md +3 -3
- data/docs/_docs/variables.md +48 -0
- data/docs/_includes/commands.html +1 -0
- data/docs/_includes/subnav.html +2 -0
- data/docs/bin/web +4 -0
- data/docs/img/tutorials/ecs-console-ufo-ship.png +0 -0
- data/docs/quick-start.md +22 -4
- data/lib/starter_project/bin/deploy +1 -1
- data/lib/starter_project/ufo/settings.yml +14 -6
- data/lib/starter_project/ufo/task_definitions.rb +13 -24
- data/lib/starter_project/ufo/variables/base.rb +6 -0
- data/lib/starter_project/ufo/variables/prod.rb +7 -0
- data/lib/starter_project/ufo/variables/stag.rb +7 -0
- data/lib/ufo.rb +3 -0
- data/lib/ufo/default/settings.yml +25 -0
- data/lib/ufo/defaults.rb +11 -10
- data/lib/ufo/dsl/task_definition.rb +31 -0
- data/lib/ufo/env.rb +18 -0
- data/lib/ufo/settings.rb +18 -12
- data/lib/ufo/version.rb +1 -1
- metadata +10 -4
- data/docs/img/tutorials/ufo-init.png +0 -0
- data/docs/img/tutorials/ufo-tasks-build.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a5d33336408ed8561e2ab17ffedba97b9e42010
|
4
|
+
data.tar.gz: 8698b1a455086430b60f59faeb222891432a8842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c299d3bdc20d6eb2b4a7ea3a729061c001b260da2f2a4216cd7643efa82210d41821a67fd625a2cadbd8b1288122646c3499890b5765715927b73464a35fb946
|
7
|
+
data.tar.gz: 13359e5a3d4f33f4e6852951097f4c88974a23b3d3183d370487aac9a74d95eff503f91b0f3149aa5431d6e49183c59e3c9370803c14fa9e65cf7d408daf6991
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [2.0.0]
|
7
|
+
* shared variable support
|
8
|
+
* UFO_ENV introduced
|
9
|
+
* settings: AWS_PROFILE and UFO_ENV mapping to ecs cluster
|
10
|
+
|
6
11
|
## [1.7.1]
|
7
12
|
* only create log group if it doesnt already exist
|
8
13
|
|
data/docs/_docs/conventions.md
CHANGED
@@ -4,6 +4,10 @@ title: Conventions
|
|
4
4
|
|
5
5
|
Ufo uses a set of naming conventions. This helps enforce some best practices and also allows the ufo commands to be concise. Ufo allows you to easily override or bypass the conventions if you need it.
|
6
6
|
|
7
|
+
### UFO_ENV to ECS Cluster Convention
|
8
|
+
|
9
|
+
By default, the ECS cluster value is the same as UFO_ENV's value. So if `UFO_ENV=prod` then the ECS Cluster is prod and if `UFO_ENV=stag` then the ECS Cluster is stag. You can easily override this convention by specifying the `--cluster` CLI option. You can also override this behavior with [settings.yml]({% link _docs/settings.md %}) to spare you from having to type `--cluster` over and over.
|
10
|
+
|
7
11
|
### Service and Task Names Convention
|
8
12
|
|
9
13
|
Ufo assumes a convention that service\_name and the task\_name are the same. If you would like to override this convention then you can specify the task name.
|
data/docs/_docs/helpers.md
CHANGED
@@ -17,6 +17,6 @@ To call the helper in task_definitions.rb you must add `helper.` in front. So f
|
|
17
17
|
|
18
18
|
The 2 classes which provide these special helper methods are in [ufo/dsl.rb](https://github.com/tongueroo/ufo/blob/master/lib/ufo/dsl.rb) and [ufo/dsl/helper.rb](https://github.com/tongueroo/ufo/blob/master/lib/ufo/dsl/helper.rb). Refer to these classes for the full list of the special variables and methods.
|
19
19
|
|
20
|
-
<a id="prev" class="btn btn-basic" href="{% link _docs/
|
20
|
+
<a id="prev" class="btn btn-basic" href="{% link _docs/variables.md %}">Back</a>
|
21
21
|
<a id="next" class="btn btn-primary" href="{% link _docs/conventions.md %}">Next Step</a>
|
22
22
|
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
|
data/docs/_docs/install.md
CHANGED
@@ -2,19 +2,9 @@
|
|
2
2
|
title: Installation
|
3
3
|
---
|
4
4
|
|
5
|
-
### Install with Bolts Toolbelt
|
6
|
-
|
7
|
-
If you want to quickly install ufo without having to worry about ufo's dependencies you can simply install the Bolts Toolbelt which has ufo included.
|
8
|
-
|
9
|
-
```sh
|
10
|
-
brew cask install boltopslabs/software/bolts
|
11
|
-
```
|
12
|
-
|
13
|
-
For more information about the Bolts Toolbelt or to get an installer for another operating system visit: [https://boltops.com/toolbelt](https://boltops.com/toolbelt)
|
14
|
-
|
15
5
|
### Install with RubyGems
|
16
6
|
|
17
|
-
|
7
|
+
You can install ufo with RubyGems:
|
18
8
|
|
19
9
|
```sh
|
20
10
|
gem install ufo
|
@@ -26,6 +16,16 @@ Or you can add ufo to your Gemfile in your project if you are working with a rub
|
|
26
16
|
gem "ufo"
|
27
17
|
{% endhighlight %}
|
28
18
|
|
19
|
+
### Install with Bolts Toolbelt
|
20
|
+
|
21
|
+
If you want to quickly install ufo without having to worry about ufo's dependencies you can simply install the Bolts Toolbelt which has ufo included.
|
22
|
+
|
23
|
+
```sh
|
24
|
+
brew cask install boltopslabs/software/bolts
|
25
|
+
```
|
26
|
+
|
27
|
+
For more information about the Bolts Toolbelt or to get an installer for another operating system visit: [https://boltops.com/toolbelt](https://boltops.com/toolbelt)
|
28
|
+
|
29
29
|
### Dependencies
|
30
30
|
|
31
31
|
* Docker: You will need a working version of [Docker](https://docs.docker.com/engine/installation/) installed as ufo shells out and calls the `docker` command.
|
data/docs/_docs/settings.md
CHANGED
@@ -2,56 +2,97 @@
|
|
2
2
|
title: Settings
|
3
3
|
---
|
4
4
|
|
5
|
-
The behavior of ufo can be configured via the `ufo/settings.yml` file. A starter `settings.yml` file is generated as part of the `ufo init` command.
|
5
|
+
The behavior of ufo can be configured via the `ufo/settings.yml` file. A starter project `ufo/settings.yml` file is generated as part of the `ufo init` command. You can have multiple settings files. The options from the files get merged and respect the following precedence:
|
6
|
+
|
7
|
+
1. current folder - The current folder's `ufo/settings.yml` values take the highest precedence.
|
8
|
+
2. user - The user's `~/.ufo/settings.yml` values take the second highest precedence.
|
9
|
+
3. default - The [default settings](https://github.com/tongueroo/ufo/blob/master/lib/ufo/default/settings.yml) bundled with the tool takes the lowest precedence.
|
10
|
+
|
11
|
+
Let's take a look at an example `ufo/settings.yml`:
|
6
12
|
|
7
13
|
```yaml
|
8
14
|
image: tongueroo/hi
|
9
15
|
clean_keep: 30
|
10
16
|
ecr_keep: 30
|
11
|
-
|
12
|
-
default:
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
aws_profile_ufo_env_map:
|
18
|
+
default: prod
|
19
|
+
# More examples:
|
20
|
+
# aws_profile1: prod
|
21
|
+
# aws_profile2: stag
|
22
|
+
# aws_profile3: dev
|
23
|
+
ufo_env_cluster_map:
|
24
|
+
default: prod
|
25
|
+
# More examples:
|
26
|
+
# aws_profile1: prod
|
27
|
+
# aws_profile2: stag
|
28
|
+
# aws_profile3: dev
|
16
29
|
```
|
17
30
|
|
18
|
-
|
31
|
+
The table below covers what each setting does:
|
32
|
+
|
33
|
+
Setting | Description
|
34
|
+
------------- | -------------
|
35
|
+
`image` | The `image` value is the name that ufo will use for the Docker image name to be built. Only provide the basename part of the image name without the tag because ufo automatically generates the tag for you. For example, `tongueroo/hi` is correct and `tongueroo/hi:my-tag` is incorrect.
|
36
|
+
`aws_profile_ufo_env_map` | Maps the `AWS_PROFILE` to the `UFO_ENV` value.
|
37
|
+
`ufo_env_cluster_map` | Maps the `UFO_ENV` to an ECS cluster value. This allows you to override the convention where the default cluster equals to `UFO_ENV`. value. This is covered in detailed at [Conventions]({% link _docs/conventions.md %}).
|
19
38
|
|
20
|
-
The `image` value is the name that ufo will use for the Docker image name to be built. Only provide the basename part of the image name without the tag. For example, `tongueroo/hi` is correct and `tongueroo/hi:my-tag` is incorrect.
|
21
39
|
|
22
|
-
### ECS Cluster
|
40
|
+
### UFO_ENV to ECS Cluster Mapping
|
23
41
|
|
24
|
-
The `
|
42
|
+
The `ufo_env_cluster_map` option allows you to override the [UFO_ENV to ECS Cluster Convention]({% link _docs/conventions.md %}). Normally, the ECS cluster defaults to whatever UFO_ENV is set to. For example, when `UFO_ENV=prod` the ECS Cluster is prod and when `UFO_ENV=stag` the ECS Cluster is stag. This setting allows you to override this behavior so that you do not have to specify the `--cluster` CLI option repeatedly. Let's go through an example:
|
43
|
+
|
44
|
+
By default:
|
25
45
|
|
26
46
|
```sh
|
27
|
-
ufo ship hi-web
|
28
|
-
ufo ship hi-web
|
29
|
-
ufo ship hi-web-stag --cluster special-cluster # overrides the default setting in `ufo/settings.yml`
|
47
|
+
UFO_ENV=prod ufo ship hi-web # cluster defaults to UFO_ENV which is prod
|
48
|
+
UFO_ENV=prod ufo ship hi-web --cluster prod # same as above
|
30
49
|
```
|
31
50
|
|
32
|
-
|
51
|
+
Override the convention and explicitly specify the `--cluster` option in the CLI.
|
33
52
|
|
34
53
|
```sh
|
35
|
-
ufo ship hi-
|
54
|
+
UFO_ENV=prod ufo ship hi-web --cluster custom-cluster # override the default UFO_ENV TO cluster mapping
|
36
55
|
```
|
37
56
|
|
38
|
-
|
39
|
-
|
40
|
-
Ufo can be configured to automatically clean old images from the ECR registry after the deploy completes.
|
57
|
+
We can also override the convention with `settings.yml`:
|
41
58
|
|
42
59
|
```yaml
|
43
|
-
|
60
|
+
ufo_env_cluster_map:
|
61
|
+
prod: custom-cluster
|
44
62
|
```
|
45
63
|
|
46
|
-
|
64
|
+
Because of the `ufo_env_cluster_map` setting, the `--cluster` CLI option is not longer required:
|
65
|
+
|
66
|
+
```sh
|
67
|
+
UFO_ENV=prod ufo ship hi-web # same as --cluster custom-cluster because of settings.yml
|
68
|
+
```
|
47
69
|
|
48
|
-
|
70
|
+
### AWS_PROFILE TO UFO_ENV Mapping
|
71
|
+
|
72
|
+
An interesting way to set `UFO_ENV` is with the `aws_profile_ufo_env_map` in `ufo/settings.yml`. Given:
|
49
73
|
|
50
74
|
```yaml
|
51
|
-
|
75
|
+
aws_profile_ufo_env_map:
|
76
|
+
default: dev
|
77
|
+
my-prod-profile: prod
|
78
|
+
my-stag-profile: stag
|
79
|
+
```
|
80
|
+
|
81
|
+
In this case, when you set `AWS_PROFILE` to switch AWS profiles, ufo picks this up and maps the `AWS_PROFILE` value to the specified `UFO_ENV` using the `aws_profile_ufo_env_map` lookup. Example:
|
82
|
+
|
83
|
+
```sh
|
84
|
+
AWS_PROFILE=my-prod-profile => UFO_ENV=prod
|
85
|
+
AWS_PROFILE=my-stag-profile => UFO_ENV=stag
|
86
|
+
AWS_PROFILE=default => UFO_ENV=dev
|
87
|
+
AWS_PROFILE=whatever => UFO_ENV=dev
|
52
88
|
```
|
53
89
|
|
90
|
+
Notice how `AWS_PROFILE=whatever` results in `UFO_ENV=dev`. This is because the `default: dev` map is specially treated. If you set the `default` map, this becomes the default value when the profile map is not specified in the rest of `ufo/settings.yml`.
|
91
|
+
|
92
|
+
This behavior prevents you from switching `AWS_PROFILE`s and then accidentally deploying a production based docker image to staging and vice versas because you forgot to also switch `LONO_ENV` to its respective environment.
|
93
|
+
|
94
|
+
|
54
95
|
<a id="prev" class="btn btn-basic" href="{% link _docs/ufo-help.md %}">Back</a>
|
55
|
-
<a id="next" class="btn btn-primary" href="{% link _docs/
|
96
|
+
<a id="next" class="btn btn-primary" href="{% link _docs/ufo-env.md %}">Next Step</a>
|
56
97
|
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
|
57
98
|
|
data/docs/_docs/structure.md
CHANGED
@@ -9,8 +9,12 @@ ufo
|
|
9
9
|
├── output
|
10
10
|
├── settings.yml
|
11
11
|
├── task_definitions.rb
|
12
|
-
|
13
|
-
|
12
|
+
├── templates
|
13
|
+
| └── main.json.erb
|
14
|
+
└── variables
|
15
|
+
├── base.rb
|
16
|
+
├── prod.rb
|
17
|
+
└── stag.rb
|
14
18
|
```
|
15
19
|
|
16
20
|
The table below covers the purpose of each folder and file.
|
@@ -22,6 +26,7 @@ File / Directory | Description
|
|
22
26
|
<code>task_definitions.rb</code> | This where you define the task definitions and specify the variables to be used by the ERB templates.
|
23
27
|
<code>templates/</code> | The ERB templates with the task definition json code. The template are covered in more detail in [ufo tasks build]({% link _docs/tutorial-ufo-tasks-build.md %}).
|
24
28
|
<code>templates/main.json.erb</code> | This is the main and starter template task definition json file that ufo initially generates.
|
29
|
+
<code>variables</code> | This is where you can define shared variables that are made available to the template_definitions.rb and your templates. More info at [Variables]({% link _docs/variables.md %}).
|
25
30
|
|
26
31
|
Now that you know where the ufo configurations are located and what they look like. Let use ufo!
|
27
32
|
|
@@ -8,12 +8,31 @@ Let's run the command in our newly clone project.
|
|
8
8
|
```sh
|
9
9
|
git clone https://github.com/tongueroo/hi.git
|
10
10
|
cd hi
|
11
|
-
ufo init --app=hi --env
|
11
|
+
ufo init --app=hi --env prod --cluster=prod --image=tongueroo/hi
|
12
12
|
```
|
13
13
|
|
14
14
|
You should see output similiar to this:
|
15
15
|
|
16
|
-
|
16
|
+
```
|
17
|
+
$ ufo init --app=hi --env prod --cluster=prod --image=tongueroo/hi
|
18
|
+
Setting up ufo project...
|
19
|
+
created: ./bin/deploy
|
20
|
+
created: ./Dockerfile
|
21
|
+
created: ./ufo/settings.yml
|
22
|
+
created: ./ufo/task_definitions.rb
|
23
|
+
created: ./ufo/templates/main.json.erb
|
24
|
+
created: ./ufo/variables/base.rb
|
25
|
+
created: ./ufo/variables/prod.rb
|
26
|
+
created: ./ufo/variables/stag.rb
|
27
|
+
created: ./.env
|
28
|
+
Starter ufo files created.
|
29
|
+
$ ufo ship hi-web
|
30
|
+
Building docker image with:
|
31
|
+
docker build -t tongueroo/hi:ufo-2017-09-10T15-00-19-c781aaf -f Dockerfile .
|
32
|
+
....
|
33
|
+
Software shipped!
|
34
|
+
$
|
35
|
+
```
|
17
36
|
|
18
37
|
The `ufo init` command generated a few starter ufo files for you. The standard directory structure of the ufo folder looks like this:
|
19
38
|
|
@@ -34,24 +53,11 @@ Take a look at the `ufo/settings.yml` file and notice that it contains some defa
|
|
34
53
|
|
35
54
|
```yaml
|
36
55
|
image: tongueroo/hi
|
37
|
-
service_cluster:
|
38
|
-
default: stag # default cluster
|
39
|
-
# can override the default cluster for each service. CLI overrides all of these settings.
|
40
|
-
hi-web-stag:
|
41
|
-
hi-clock-stag:
|
42
|
-
hi-worker-stag:
|
43
56
|
```
|
44
57
|
|
45
58
|
The `image` value is the name that ufo will use as a base to generate a Docker image name.
|
46
59
|
|
47
|
-
The
|
48
|
-
|
49
|
-
```
|
50
|
-
ufo ship hi-web-stag --cluster hi-cluster
|
51
|
-
ufo ship hi-web-stag # same as above because it is configured in ufo/settings.yml
|
52
|
-
ufo ship hi-web-stag --cluster special-cluster # overrides the default setting in `ufo/settings.yml`.
|
53
|
-
```
|
54
|
-
|
60
|
+
The other settings are optional. You can learn more about them at [Settings]({% link _docs/settings.md %}).
|
55
61
|
|
56
62
|
<a id="prev" class="btn btn-basic" href="{% link _docs/tutorial.md %}">Back</a>
|
57
63
|
<a id="next" class="btn btn-primary" href="{% link _docs/tutorial-ufo-docker-build.md %}">Next Step</a>
|
@@ -7,53 +7,54 @@ title: Deploy One App
|
|
7
7
|
In this guide we have walked through what ufo does step by step. First ufo builds the Docker image with `ufo docker build`. Then it will build and register the ECS task definitions with the `ufo tasks` commands. Now we'll deploy the code to ECS.
|
8
8
|
|
9
9
|
```sh
|
10
|
-
ufo ship hi-web
|
10
|
+
ufo ship hi-web
|
11
11
|
```
|
12
12
|
|
13
|
-
|
13
|
+
By convention, ufo will ship the docker container to an ECS cluster with the same value as UFO_ENV, which defaults to prod. So the command above is the same as:
|
14
14
|
|
15
|
-
```
|
16
|
-
ufo ship hi-web
|
15
|
+
```sh
|
16
|
+
ufo ship hi-web --cluster prod
|
17
|
+
UFO_ENV=prod ufo ship hi-web --cluster prod
|
17
18
|
```
|
18
19
|
|
19
|
-
When you run `ufo ship hi-web
|
20
|
+
When you run `ufo ship hi-web`:
|
20
21
|
|
21
22
|
1. It builds the docker image.
|
22
23
|
2. Generates a task definition and registers it.
|
23
24
|
3. Updates the ECS service to use it.
|
24
25
|
|
25
|
-
If the ECS service hi-web
|
26
|
+
If the ECS service hi-web does not yet exist, ufo will create the service for you. Ufo will also automatically create the ECS cluster. If you are relying on this tool to create the cluster, you still need to associate ECS Container Instances to the cluster yourself.
|
26
27
|
|
27
28
|
By convention, if the service has a container name web, you'll get prompted to create an ELB and specify a target group arn. The ELB and target group must already exist. You can bypass the prompt and specify the target group ARN as part of the ship command or with the `--no-target-group-prompt` option. The elb target group only gets associated with the ECS service if the service is being created for the first time. If the service already exists then the `--target-group` parameter just gets ignored and the ECS task simply gets updated. Example:
|
28
29
|
|
29
30
|
|
30
31
|
```bash
|
31
|
-
ufo ship hi-web
|
32
|
+
ufo ship hi-web --target-group=arn:aws:elasticloadbalancing:us-east-1:12345689:targetgroup/hi-web/12345
|
32
33
|
```
|
33
34
|
|
34
35
|
Let's go back to the original command and take a look at the output:
|
35
36
|
|
36
37
|
```sh
|
37
|
-
ufo ship hi-web
|
38
|
+
ufo ship hi-web
|
38
39
|
```
|
39
40
|
|
40
41
|
The output should look something like this (some of the output has been removed for conciseness):
|
41
42
|
|
42
43
|
```sh
|
43
|
-
$ ufo ship hi-web
|
44
|
+
$ ufo ship hi-web
|
44
45
|
Building docker image with:
|
45
46
|
docker build -t tongueroo/hi:ufo-2017-06-12T06-46-12-a18aa30 -f Dockerfile .
|
46
47
|
...
|
47
48
|
Pushed tongueroo/hi:ufo-2017-06-12T06-46-12-a18aa30 docker image. Took 9s.
|
48
49
|
Building Task Definitions...
|
49
50
|
Generating Task Definitions:
|
50
|
-
ufo/output/hi-web
|
51
|
-
ufo/output/hi-worker
|
52
|
-
ufo/output/hi-clock
|
51
|
+
ufo/output/hi-web.json
|
52
|
+
ufo/output/hi-worker.json
|
53
|
+
ufo/output/hi-clock.json
|
53
54
|
Task Definitions built in ufo/output.
|
54
|
-
hi-web
|
55
|
-
Shipping hi-web
|
56
|
-
hi-web
|
55
|
+
hi-web task definition registered.
|
56
|
+
Shipping hi-web...
|
57
|
+
hi-web service updated on stag cluster with task hi-web
|
57
58
|
Software shipped!
|
58
59
|
Cleaning up docker images...
|
59
60
|
Running: docker rmi tongueroo/hi:ufo-2017-06-11T20-32-16-a18aa30 tongueroo/hi:ufo-2017-06-11T20-27-44-bc80e84 tongueroo/hi:ufo-2017-06-11T20-02-18-bc80e84
|
@@ -72,14 +73,14 @@ The `ufo ship` command will automatically calls the steps we called manually in
|
|
72
73
|
If you would like to skip the first 2 steps you can use the `--no-docker` and `--no-tasks` flags:
|
73
74
|
|
74
75
|
```sh
|
75
|
-
ufo ship hi-web
|
76
|
+
ufo ship hi-web --no-docker --no-tasks
|
76
77
|
```
|
77
78
|
|
78
79
|
The output should look something like this:
|
79
80
|
|
80
81
|
```sh
|
81
|
-
Shipping hi-web
|
82
|
-
hi-web
|
82
|
+
Shipping hi-web...
|
83
|
+
hi-web service updated on stag cluster with task hi-web
|
83
84
|
Software shipped!
|
84
85
|
```
|
85
86
|
|
@@ -9,9 +9,9 @@ These processes use the same codebase and same docker image, but have slightly d
|
|
9
9
|
While we can use the `ufo ship` command to deploy to all 3 service roles individually like so:
|
10
10
|
|
11
11
|
```sh
|
12
|
-
ufo ship hi-web
|
13
|
-
ufo ship hi-worker
|
14
|
-
ufo ship hi-clock
|
12
|
+
ufo ship hi-web
|
13
|
+
ufo ship hi-worker
|
14
|
+
ufo ship hi-clock
|
15
15
|
```
|
16
16
|
|
17
17
|
This would build a new Docker image for each process. We actually want have the same docker image running on all of these roles. In this case where we want to use the *same* Docker image for all 3 roles, ufo provides a `ufo ships` command.
|
@@ -19,7 +19,7 @@ This would build a new Docker image for each process. We actually want have the
|
|
19
19
|
### ufo ships
|
20
20
|
|
21
21
|
```sh
|
22
|
-
ufo ships hi-web
|
22
|
+
ufo ships hi-web hi-worker hi-clock
|
23
23
|
```
|
24
24
|
|
25
25
|
You can check on the ECS console and should see something similar to this:
|
@@ -29,7 +29,7 @@ You can check on the ECS console and should see something similar to this:
|
|
29
29
|
You can shorten the command by taking advantage of shell expansion:
|
30
30
|
|
31
31
|
```sh
|
32
|
-
ufo ships hi-{web,worker,clock}
|
32
|
+
ufo ships hi-{web,worker,clock}
|
33
33
|
```
|
34
34
|
|
35
35
|
<a id="prev" class="btn btn-basic" href="{% link _docs/tutorial-ufo-ship.md %}">Back</a>
|
@@ -13,7 +13,7 @@ Let's take a look at the 2 files that are used by ufo to build the the ECS task
|
|
13
13
|
|
14
14
|
Ufo task definitions are written as an ERB template that makes it every easily accessible and configurable to your requirements. Here is is an example of an ERB template `ufo/templates/main.json.erb` that shows how easy it is to modfied the task definition you want to be uploaded by ufo:
|
15
15
|
|
16
|
-
**main.json.erb**:
|
16
|
+
**ufo/templates/main.json.erb**:
|
17
17
|
|
18
18
|
```json
|
19
19
|
{
|
@@ -27,30 +27,7 @@ Ufo task definitions are written as an ERB template that makes it every easily a
|
|
27
27
|
"memory": <%= @memory %>,
|
28
28
|
<% end %>
|
29
29
|
<% if @memory_reservation %>
|
30
|
-
|
31
|
-
<% end %>
|
32
|
-
<% if @container_port %>
|
33
|
-
"portMappings": [
|
34
|
-
{
|
35
|
-
"containerPort": "<%= @container_port %>",
|
36
|
-
"protocol": "tcp"
|
37
|
-
}
|
38
|
-
],
|
39
|
-
<% end %>
|
40
|
-
"command": <%= @command.to_json %>,
|
41
|
-
<% if @environment %>
|
42
|
-
"environment": <%= @environment.to_json %>,
|
43
|
-
<% end %>
|
44
|
-
<% if @awslogs_group %>
|
45
|
-
"logConfiguration": {
|
46
|
-
"logDriver": "awslogs",
|
47
|
-
"options": {
|
48
|
-
"awslogs-group": "<%= @awslogs_group %>",
|
49
|
-
"awslogs-region": "<%= @awslogs_region || 'us-east-1' %>",
|
50
|
-
"awslogs-stream-prefix": "<%= @awslogs_stream_prefix %>"
|
51
|
-
}
|
52
|
-
},
|
53
|
-
<% end %>
|
30
|
+
...
|
54
31
|
"essential": true
|
55
32
|
}
|
56
33
|
]
|
@@ -59,52 +36,50 @@ Ufo task definitions are written as an ERB template that makes it every easily a
|
|
59
36
|
|
60
37
|
The instance variable values are specified in `ufo/task_definitions.rb` via a DSL. Here's the file:
|
61
38
|
|
62
|
-
**task_definitions.rb**:
|
39
|
+
**ufo/task_definitions.rb**:
|
63
40
|
|
64
41
|
```
|
65
|
-
|
66
|
-
common = {
|
67
|
-
image: helper.full_image_name, # includes the git sha tongueroo/hi:ufo-[sha].
|
68
|
-
cpu: 128,
|
69
|
-
memory_reservation: 256,
|
70
|
-
environment: helper.env_file(".env")
|
71
|
-
# another example
|
72
|
-
# environment: helper.env_vars(%Q{
|
73
|
-
# RAILS_ENV=production
|
74
|
-
# SECRET_KEY_BASE=secret
|
75
|
-
# })
|
76
|
-
}
|
77
|
-
|
78
|
-
task_definition "hi-web-stag" do
|
42
|
+
task_definition "hi-web" do
|
79
43
|
source "main" # will use ufo/templates/main.json.erb
|
80
|
-
variables(
|
44
|
+
variables(
|
81
45
|
family: task_definition_name,
|
82
46
|
name: "web",
|
83
47
|
container_port: helper.dockerfile_port,
|
84
48
|
command: ["bin/web"]
|
85
|
-
)
|
49
|
+
)
|
86
50
|
end
|
87
51
|
|
88
|
-
task_definition "hi-worker
|
52
|
+
task_definition "hi-worker" do
|
89
53
|
source "main" # will use ufo/templates/main.json.erb
|
90
|
-
variables(
|
54
|
+
variables(
|
91
55
|
family: task_definition_name,
|
92
56
|
name: "worker",
|
93
57
|
command: ["bin/worker"]
|
94
|
-
)
|
58
|
+
)
|
95
59
|
end
|
60
|
+
```
|
96
61
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
62
|
+
The shared variables are set in the variables folder:
|
63
|
+
|
64
|
+
**ufo/variables/base.rb**:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
@image = helper.full_image_name # includes the git sha tongueroo/hi:ufo-[sha].
|
68
|
+
@cpu = 128
|
69
|
+
@memory_reservation = 256
|
70
|
+
@environment = helper.env_file(".env")
|
71
|
+
```
|
72
|
+
|
73
|
+
**ufo/variables/prod.rb**:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
@environment = helper.env_vars(%Q{
|
77
|
+
RAILS_ENV=production
|
78
|
+
SECRET_KEY_BASE=secret
|
79
|
+
})
|
105
80
|
```
|
106
81
|
|
107
|
-
Ufo
|
82
|
+
Ufo combines the `main.json.erb` template, `task_definitions.rb` definitions, and variables in the `ufo/variables` folder. It then generates the raw AWS formatted task definition in the `output` folder.
|
108
83
|
|
109
84
|
If you need to modify the task definition template to suite your own needs it is super simple, just edit `main.json.erb`. You do not have to dive deep into internal code somewhere. It is all there for you to fully control.
|
110
85
|
|
@@ -118,17 +93,26 @@ ufo tasks build
|
|
118
93
|
|
119
94
|
You should see output similar to below:
|
120
95
|
|
121
|
-
|
96
|
+
```sh
|
97
|
+
$ ufo tasks build
|
98
|
+
Building Task Definitions...
|
99
|
+
Generating Task Definitions:
|
100
|
+
ufo/output/hi-web.json
|
101
|
+
ufo/output/hi-worker.json
|
102
|
+
ufo/output/hi-clock.json
|
103
|
+
Task Definitions built in ufo/output.
|
104
|
+
$
|
105
|
+
```
|
122
106
|
|
123
|
-
Let's take a look at one of the generated files: `ufo/output/hi-web
|
107
|
+
Let's take a look at one of the generated files: `ufo/output/hi-web.json`.
|
124
108
|
|
125
109
|
```json
|
126
110
|
{
|
127
|
-
"family": "hi-web
|
111
|
+
"family": "hi-web",
|
128
112
|
"containerDefinitions": [
|
129
113
|
{
|
130
114
|
"name": "web",
|
131
|
-
"image": "tongueroo/hi:ufo-2017-
|
115
|
+
"image": "tongueroo/hi:ufo-2017-09-10T15-13-14-1105f71",
|
132
116
|
"cpu": 128,
|
133
117
|
"memoryReservation": 256,
|
134
118
|
"portMappings": [
|
@@ -143,13 +127,16 @@ Let's take a look at one of the generated files: `ufo/output/hi-web-stag.json`.
|
|
143
127
|
"environment": [
|
144
128
|
{
|
145
129
|
"name": "RAILS_ENV",
|
146
|
-
"value": "
|
130
|
+
"value": "production"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"name": "SECRET_KEY_BASE",
|
134
|
+
"value": "secret"
|
147
135
|
}
|
148
136
|
],
|
149
137
|
"essential": true
|
150
138
|
}
|
151
139
|
]
|
152
|
-
}
|
153
140
|
```
|
154
141
|
|
155
142
|
### Register the ECS Task Definitions
|
@@ -163,9 +150,9 @@ ufo tasks register
|
|
163
150
|
You should see something similiar to this:
|
164
151
|
|
165
152
|
```sh
|
166
|
-
hi-clock
|
167
|
-
hi-web
|
168
|
-
hi-worker
|
153
|
+
hi-clock task definition registered.
|
154
|
+
hi-web task definition registered.
|
155
|
+
hi-worker task definition registered.
|
169
156
|
```
|
170
157
|
|
171
158
|
<a id="prev" class="btn btn-basic" href="{% link _docs/tutorial-ufo-docker-build.md %}">Back</a>
|