ufo 2.3.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +57 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +16 -1
- data/Gemfile.lock +16 -3
- data/README.md +5 -1
- data/docs/_docs/auto-completion.md +27 -0
- data/docs/_docs/automated-cleanup.md +1 -1
- data/docs/_docs/conventions.md +2 -2
- data/docs/_docs/helpers.md +6 -6
- data/docs/_docs/run-in-pieces.md +15 -8
- data/docs/_docs/settings.md +61 -49
- data/docs/_docs/structure.md +2 -2
- data/docs/_docs/tutorial-ufo-docker-build.md +10 -3
- data/docs/_docs/tutorial-ufo-init.md +48 -16
- data/docs/_docs/tutorial-ufo-ship.md +14 -7
- data/docs/_docs/tutorial-ufo-ships.md +1 -1
- data/docs/_docs/tutorial-ufo-tasks-build.md +23 -14
- data/docs/_docs/ufo-deploy.md +30 -0
- data/docs/_docs/ufo-docker-base.md +3 -3
- data/docs/_docs/ufo-docker-build.md +3 -3
- data/docs/_docs/ufo-docker-push.md +43 -0
- data/docs/_docs/ufo-env.md +17 -15
- data/docs/_docs/ufo-init.md +14 -1
- data/docs/_docs/ufo-scale.md +2 -4
- data/docs/_docs/ufo-ships.md +2 -2
- data/docs/_docs/variables.md +6 -6
- data/docs/_includes/commands.html +4 -4
- data/docs/_includes/subnav.html +3 -0
- data/docs/_includes/summary.html +2 -2
- data/docs/_includes/ufo-ship-options.md +0 -2
- data/docs/docs.md +5 -1
- data/docs/quick-start.md +19 -10
- data/lib/{starter_project → template}/.env +0 -0
- data/lib/template/.ufo/settings.yml.tt +27 -0
- data/lib/{starter_project/ufo/task_definitions.rb → template/.ufo/task_definitions.rb.tt} +0 -0
- data/lib/{starter_project/ufo → template/.ufo}/templates/main.json.erb +0 -0
- data/lib/{starter_project/ufo → template/.ufo}/variables/base.rb +0 -0
- data/lib/{starter_project/ufo → template/.ufo}/variables/development.rb +0 -0
- data/lib/{starter_project/ufo → template/.ufo}/variables/production.rb +0 -0
- data/lib/{starter_project → template}/Dockerfile +0 -0
- data/lib/{starter_project/bin/deploy → template/bin/deploy.tt} +0 -0
- data/lib/ufo.rb +9 -2
- data/lib/ufo/cli.rb +34 -29
- data/lib/ufo/completer.rb +86 -64
- data/lib/ufo/core.rb +42 -0
- data/lib/ufo/default.rb +4 -6
- data/lib/ufo/default/settings.yml +24 -22
- data/lib/ufo/deploy.rb +0 -0
- data/lib/ufo/docker.rb +12 -2
- data/lib/ufo/docker/builder.rb +19 -49
- data/lib/ufo/docker/cleaner.rb +4 -2
- data/lib/ufo/docker/dockerfile.rb +1 -2
- data/lib/ufo/docker/pusher.rb +53 -0
- data/lib/ufo/dsl.rb +1 -2
- data/lib/ufo/dsl/helper.rb +3 -4
- data/lib/ufo/dsl/outputter.rb +1 -1
- data/lib/ufo/dsl/task_definition.rb +17 -37
- data/lib/ufo/ecr/auth.rb +22 -2
- data/lib/ufo/ecs.rb +5 -0
- data/lib/ufo/ecs/service.rb +21 -0
- data/lib/ufo/help/completion.md +1 -1
- data/lib/ufo/help/completion_script.md +1 -1
- data/lib/ufo/help/deploy.md +14 -0
- data/lib/ufo/help/docker/name.md +13 -2
- data/lib/ufo/help/docker/push.md +11 -0
- data/lib/ufo/init.rb +48 -65
- data/lib/ufo/log_group.rb +5 -2
- data/lib/ufo/sequence.rb +27 -0
- data/lib/ufo/setting.rb +18 -8
- data/lib/ufo/ship.rb +23 -46
- data/lib/ufo/tasks/builder.rb +8 -11
- data/lib/ufo/tasks/register.rb +2 -3
- data/lib/ufo/upgrade3.rb +64 -0
- data/lib/ufo/util.rb +0 -2
- data/lib/ufo/version.rb +1 -1
- data/spec/fixtures/home_existing/.docker/config.json +1 -1
- data/spec/fixtures/settings.yml +23 -0
- data/spec/lib/cli_spec.rb +1 -9
- data/spec/lib/completion_spec.rb +18 -0
- data/spec/lib/core_spec.rb +16 -0
- data/spec/lib/ecr_auth_spec.rb +1 -3
- data/spec/lib/ecr_cleaner_spec.rb +1 -3
- data/spec/lib/setting_spec.rb +12 -0
- data/spec/lib/ship_spec.rb +2 -4
- data/spec/lib/task_spec.rb +0 -2
- data/spec/spec_helper.rb +12 -2
- data/ufo.gemspec +2 -0
- metadata +47 -13
- data/lib/starter_project/ufo/settings.yml +0 -18
- data/lib/ufo/env.rb +0 -18
- data/lib/ufo/help/sub/goodbye.md +0 -5
data/docs/_docs/structure.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
title: Structure
|
3
3
|
---
|
4
4
|
|
5
|
-
Ufo creates a ufo folder within your project which contains the required files used by ufo to build and deploy docker images to ECS. The standard directory structure of the ufo folder looks like this:
|
5
|
+
Ufo creates a `.ufo` folder within your project which contains the required files used by ufo to build and deploy docker images to ECS. The standard directory structure of the `.ufo` folder looks like this:
|
6
6
|
|
7
7
|
```sh
|
8
|
-
ufo
|
8
|
+
.ufo
|
9
9
|
├── output
|
10
10
|
├── settings.yml
|
11
11
|
├── task_definitions.rb
|
@@ -48,19 +48,26 @@ $
|
|
48
48
|
|
49
49
|
As you can see `ufo docker build` effectively shells out and calls `docker build -t tongueroo/hi:ufo-2017-06-11T22-18-03-a18aa30 -f Dockerfile .`. The docker image tag that is generated contains a useful timestamp and the current HEAD git sha of the project that you are on.
|
50
50
|
|
51
|
-
By default when you are running `ufo docker build` directly it does not push the docker image to the registry. If you would like it to
|
51
|
+
By default when you are running `ufo docker build` directly it does not push the docker image to the registry. If you would like it to push the built image to a registry at the end of the build use the `--push` flag.
|
52
52
|
|
53
53
|
```sh
|
54
54
|
ufo docker build --push
|
55
55
|
```
|
56
56
|
|
57
|
-
You
|
57
|
+
You can also use the `ufo docker push` command which will push the last built image from `ufo docker build`.
|
58
|
+
|
59
|
+
```
|
60
|
+
ufo docker push
|
61
|
+
```
|
62
|
+
|
63
|
+
You should see the image being pushed with a message that looks something like this:
|
58
64
|
|
59
65
|
```sh
|
60
66
|
Pushed tongueroo/hi:ufo-2017-06-11T22-22-32-a18aa30 docker image. Took 9s.
|
61
67
|
```
|
62
68
|
|
63
|
-
|
69
|
+
|
70
|
+
Note in order to push the image to a registry you will need to login into the registry. If you are using DockerHub use the `docker login` command. If you are using AWS ECR then you can use the `aws ecr get-login` command.
|
64
71
|
|
65
72
|
<a id="prev" class="btn btn-basic" href="{% link _docs/tutorial-ufo-init.md %}">Back</a>
|
66
73
|
<a id="next" class="btn btn-primary" href="{% link _docs/tutorial-ufo-tasks-build.md %}">Next Step</a>
|
@@ -13,18 +13,19 @@ ufo init --app=hi --image=tongueroo/hi
|
|
13
13
|
|
14
14
|
You should see output similiar to this:
|
15
15
|
|
16
|
-
```
|
16
|
+
```sh
|
17
17
|
$ ufo init --app=hi --image=tongueroo/hi
|
18
18
|
Setting up ufo project...
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
create .env
|
20
|
+
create .ufo/settings.yml
|
21
|
+
create .ufo/task_definitions.rb
|
22
|
+
create .ufo/templates/main.json.erb
|
23
|
+
create .ufo/variables/base.rb
|
24
|
+
create .ufo/variables/development.rb
|
25
|
+
create .ufo/variables/production.rb
|
26
|
+
create Dockerfile
|
27
|
+
create bin/deploy
|
28
|
+
append .gitignore
|
28
29
|
Starter ufo files created.
|
29
30
|
$ ufo ship hi-web
|
30
31
|
Building docker image with:
|
@@ -37,25 +38,56 @@ $
|
|
37
38
|
The `ufo init` command generated a few starter ufo files for you. The standard directory structure of the ufo folder looks like this:
|
38
39
|
|
39
40
|
```sh
|
40
|
-
ufo
|
41
|
+
.ufo
|
41
42
|
├── output
|
42
43
|
├── settings.yml
|
43
44
|
├── task_definitions.rb
|
44
|
-
|
45
|
-
|
45
|
+
├── templates
|
46
|
+
| └── main.json.erb
|
47
|
+
└── variables
|
48
|
+
├── base.rb
|
49
|
+
├── prod.rb
|
50
|
+
└── stag.rb
|
46
51
|
```
|
47
52
|
|
48
53
|
The explanation of the folders and files were covered in detailed earlier at [Structure]({% link _docs/structure.md %}).
|
49
54
|
|
50
55
|
### Settings
|
51
56
|
|
52
|
-
Take a look at the `
|
57
|
+
Take a look at the `settings.yml` file and notice that it contains some default configuration settings so you do not have to type out these options repeatedly for some of the ufo commands.
|
53
58
|
|
54
59
|
```yaml
|
55
|
-
|
60
|
+
# More info: http://ufoships.com/docs/ufo-settings/
|
61
|
+
base: &base
|
62
|
+
image: tongueroo/hi
|
63
|
+
# clean_keep: 30 # cleans up docker images on your docker server.
|
64
|
+
# ecr_keep: 30 # cleans up images on ECR and keeps this remaining amount. Defaults to keep all.
|
65
|
+
# defaults when an new ECS service is created by ufo ship
|
66
|
+
new_service:
|
67
|
+
maximum_percent: 200
|
68
|
+
minimum_healthy_percent: 100
|
69
|
+
desired_count: 1
|
70
|
+
|
71
|
+
development:
|
72
|
+
<<: *base
|
73
|
+
# cluster: dev # uncomment if you want the cluster name be other than the default
|
74
|
+
# the default is to match UFO_ENV. So UFO_ENV=development means the ECS
|
75
|
+
# cluster will be name development
|
76
|
+
# When you have AWS_PROFILE set to one of these values, ufo will switch to the desired
|
77
|
+
# environment. This prevents you from switching AWS_PROFILE, forgetting to
|
78
|
+
# also switch UFO_ENV, and accidentally deploying to production vs development.
|
79
|
+
# aws_profiles:
|
80
|
+
# - dev_profile1
|
81
|
+
# - dev_profile2
|
82
|
+
|
83
|
+
production:
|
84
|
+
<<: *base
|
85
|
+
# cluster: prod
|
86
|
+
# aws_profiles:
|
87
|
+
# - prod_profile
|
56
88
|
```
|
57
89
|
|
58
|
-
The `image` value is the name that ufo will use as a base to generate a Docker image name.
|
90
|
+
The `image` value is the name that ufo will use as a base portion of the name to generate a Docker image name, it should not include the tag portion.
|
59
91
|
|
60
92
|
The other settings are optional. You can learn more about them at [Settings]({% link _docs/settings.md %}).
|
61
93
|
|
@@ -10,10 +10,10 @@ In this guide we have walked through what ufo does step by step. First ufo buil
|
|
10
10
|
ufo ship hi-web
|
11
11
|
```
|
12
12
|
|
13
|
-
By convention, ufo will ship the docker container to an ECS cluster with the same value as UFO_ENV, which defaults to
|
13
|
+
By convention, ufo will ship the docker container to an ECS cluster with the same value as UFO_ENV, which defaults to development. So the command above is the same as:
|
14
14
|
|
15
15
|
```sh
|
16
|
-
ufo ship hi-web --cluster
|
16
|
+
ufo ship hi-web --cluster production
|
17
17
|
UFO_ENV=production ufo ship hi-web --cluster prod
|
18
18
|
```
|
19
19
|
|
@@ -23,7 +23,9 @@ When you run `ufo ship hi-web`:
|
|
23
23
|
2. Generates a task definition and registers it.
|
24
24
|
3. Updates the ECS service to use it.
|
25
25
|
|
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.
|
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.
|
27
|
+
|
28
|
+
NOTE: If you are relying on this tool to create the cluster, you still need to associate ECS Container Instances to the cluster yourself.
|
27
29
|
|
28
30
|
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:
|
29
31
|
|
@@ -66,14 +68,19 @@ Checking the ECS console you should see something like this:
|
|
66
68
|
|
67
69
|
You have successfully shipped a docker image to ECS! 🍾🥂
|
68
70
|
|
69
|
-
### Skipping Previous Steps
|
71
|
+
### Skipping Previous Steps Method
|
72
|
+
|
73
|
+
You should notice that `ufo ship` re-built the docker image and re-registered the task definitions. The `ufo ship` command is designed to run everything in one simple command, so we do not have to manually call the commands in the previous pages: `ufo build` and `ufo tasks`.
|
74
|
+
|
75
|
+
If you would like to skip the first 2 steps, then you can use the [ufo deploy]({% link _docs/ufo-deploy.md %}) instead. The `ufo deploy` command will:
|
70
76
|
|
71
|
-
|
77
|
+
1. register the task definition in `.ufo/output/hi-web.json` unmodified
|
78
|
+
2. update the ECS service
|
72
79
|
|
73
|
-
|
80
|
+
Example:
|
74
81
|
|
75
82
|
```sh
|
76
|
-
ufo
|
83
|
+
ufo deploy hi-web
|
77
84
|
```
|
78
85
|
|
79
86
|
The output should look something like this:
|
@@ -2,7 +2,7 @@
|
|
2
2
|
title: Deploy Multiple Apps
|
3
3
|
---
|
4
4
|
|
5
|
-
You might have noticed in in the tutorial that the generated starter ufo folder contains 3 task definitions a web
|
5
|
+
You might have noticed in in the tutorial that the generated starter ufo folder contains 3 task definitions a `web`, `worker` and `clock` role. This is a common pattern. The web process handles web traffic, the worker process handles background job processing that would be too slow and potentially block web requests, and a clock process is typically used to schedule recurring jobs.
|
6
6
|
|
7
7
|
These processes use the same codebase and same docker image, but have slightly different run time settings. The docker run command for a web process could be [puma](http://puma.io/) and the command for a worker process could be [sidekiq](http://sidekiq.org/). Environment variables are also sometimes different. The important key is that the same docker image is used for all 3 services but the task definition for each service is slightly different.
|
8
8
|
|
@@ -59,7 +59,9 @@ task_definition "hi-worker" do
|
|
59
59
|
end
|
60
60
|
```
|
61
61
|
|
62
|
-
|
62
|
+
### Shared Variables
|
63
|
+
|
64
|
+
Ufo has a concept of shared variables, covered in [Shared Variables]({% link _docs/variables.md %}). The shared variables are set in the `variables` folder and essentially allow you to use a set of shared variables through your templates:
|
63
65
|
|
64
66
|
**ufo/variables/base.rb**:
|
65
67
|
|
@@ -70,11 +72,11 @@ The shared variables are set in the variables folder:
|
|
70
72
|
@environment = helper.env_file(".env")
|
71
73
|
```
|
72
74
|
|
73
|
-
**ufo/variables/
|
75
|
+
**ufo/variables/development.rb**:
|
74
76
|
|
75
77
|
```ruby
|
76
78
|
@environment = helper.env_vars(%Q{
|
77
|
-
RAILS_ENV=
|
79
|
+
RAILS_ENV=development
|
78
80
|
SECRET_KEY_BASE=secret
|
79
81
|
})
|
80
82
|
```
|
@@ -97,10 +99,10 @@ You should see output similar to below:
|
|
97
99
|
$ ufo tasks build
|
98
100
|
Building Task Definitions...
|
99
101
|
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
|
102
|
+
.ufo/output/hi-web.json
|
103
|
+
.ufo/output/hi-worker.json
|
104
|
+
.ufo/output/hi-clock.json
|
105
|
+
Task Definitions built in .ufo/output
|
104
106
|
$
|
105
107
|
```
|
106
108
|
|
@@ -112,8 +114,8 @@ Let's take a look at one of the generated files: `ufo/output/hi-web.json`.
|
|
112
114
|
"containerDefinitions": [
|
113
115
|
{
|
114
116
|
"name": "web",
|
115
|
-
"image": "tongueroo/hi:ufo-
|
116
|
-
"cpu":
|
117
|
+
"image": "tongueroo/hi:ufo-2018-02-13T11-33-15-27aa242",
|
118
|
+
"cpu": 192,
|
117
119
|
"memoryReservation": 256,
|
118
120
|
"portMappings": [
|
119
121
|
{
|
@@ -121,27 +123,34 @@ Let's take a look at one of the generated files: `ufo/output/hi-web.json`.
|
|
121
123
|
"protocol": "tcp"
|
122
124
|
}
|
123
125
|
],
|
124
|
-
"command":
|
125
|
-
"bin/web"
|
126
|
-
],
|
126
|
+
"command": null,
|
127
127
|
"environment": [
|
128
128
|
{
|
129
129
|
"name": "RAILS_ENV",
|
130
|
-
"value": "
|
130
|
+
"value": "development"
|
131
131
|
},
|
132
132
|
{
|
133
133
|
"name": "SECRET_KEY_BASE",
|
134
134
|
"value": "secret"
|
135
135
|
}
|
136
136
|
],
|
137
|
+
"logConfiguration": {
|
138
|
+
"logDriver": "awslogs",
|
139
|
+
"options": {
|
140
|
+
"awslogs-group": "ecs/hi-web",
|
141
|
+
"awslogs-region": "us-east-1",
|
142
|
+
"awslogs-stream-prefix": "hi"
|
143
|
+
}
|
144
|
+
},
|
137
145
|
"essential": true
|
138
146
|
}
|
139
147
|
]
|
148
|
+
}
|
140
149
|
```
|
141
150
|
|
142
151
|
### Register the ECS Task Definitions
|
143
152
|
|
144
|
-
You have built the ecs task definitions locally on your machine. To register the task definitions in output run
|
153
|
+
You have built the ecs task definitions locally on your machine. To register the task definitions in the `output` folder run:
|
145
154
|
|
146
155
|
```sh
|
147
156
|
ufo tasks register
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
title: ufo deploy
|
3
|
+
---
|
4
|
+
|
5
|
+
It is useful to sometimes deploy only the task definition without re-building it. Say for example, you are debugging the task definition and just want to directly edit the `.ufo/output/hi-web.json` definition. You can accomplish this with the `ufo deploy` command. The `ufo deploy` command will deploy the task definition in `.ufo/output` unmodified. Example:
|
6
|
+
|
7
|
+
```
|
8
|
+
ufo deploy hi-web
|
9
|
+
```
|
10
|
+
|
11
|
+
The above command does the following:
|
12
|
+
|
13
|
+
1. register the `.ufo/output/hi-web.json` task definition to ECS untouched.
|
14
|
+
2. deploys it to ECS by updating the service
|
15
|
+
|
16
|
+
The `ufo deploy` command does less than the `ufo ship` command. Typically, people use [ufo ship]({% link _docs/ufo-ship.md %}) over the `ufo deploy` command do everything in one step:
|
17
|
+
|
18
|
+
1. build the Docker image
|
19
|
+
2. register the ECS task definition
|
20
|
+
3. update the ECS service
|
21
|
+
|
22
|
+
The `ufo ships`, `ufo ship`, `ufo deploy` command support the same options. The options are presented here again for convenience:
|
23
|
+
|
24
|
+
{% include ufo-ship-options.md %}
|
25
|
+
|
26
|
+
|
27
|
+
<a id="prev" class="btn btn-basic" href="{% link _docs/ufo-ships.md %}">Back</a>
|
28
|
+
<a id="next" class="btn btn-primary" href="{% link _docs/ufo-scale.md %}">Next Step</a>
|
29
|
+
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
|
30
|
+
|
@@ -8,7 +8,7 @@ Docker is fantastic and has given developers more power and control over the OS
|
|
8
8
|
|
9
9
|
The `ufo docker base` commands allows you to build an Docker image from `Dockerfile.base` to be used as a cache and in the FROM instruction in the main `Dockerfile`. This base Docker cache image technique speeds up development substantially if you have dependencies like gems in your project. Let's say you have 20 gems in your project and are actively developing your project. You are experimenting with 3 different gems, adding and removing them while you are investigating the best gem to use. Without the Docker image cache that already has all of your other gems installed each time you adjust `Gemfile` it would have to wait until all the gems from scratch again installed again.
|
10
10
|
|
11
|
-
There are pros and cons of using this approach. Remember there are 2 hard problems in computer science: 1. Naming and 2. Caching. The main con about this approach is if you forget to update the base Docker image you will have cached artifacts that will not disappear unless you rebuild the base Docker image. While some folks are completely against introducing this cache layer, some have found it being a huge win in speeding up their Docker development workflow. If you are using this technique it is recommended that you set up some automation that
|
11
|
+
There are pros and cons of using this approach. Remember there are 2 hard problems in computer science: 1. Naming and 2. Caching. The main con about this approach is if you forget to update the base Docker image you will have cached artifacts that will not disappear unless you rebuild the base Docker image. While some folks are completely against introducing this cache layer, some have found it being a huge win in speeding up their Docker development workflow. If you are using this technique it is recommended that you set up some automation that rebuilds the base Docker image at least nightly.
|
12
12
|
|
13
13
|
### Demo
|
14
14
|
|
@@ -34,9 +34,9 @@ docker build -t tongueroo/hi:base-2017-06-12T14-36-44-2af505e -f Dockerfile.base
|
|
34
34
|
|
35
35
|
It is using the docker `-f Dockerfile.base` option to build the base image. It names the image with `tongueroo/hi:base-2017-06-12T14-36-44-2af505e`. The image tag contains useful information: the timestamp when the image was built and the exact git sha of the code. The image gets push to a registry immediately.
|
36
36
|
|
37
|
-
Notice at the very end, the *current* `Dockerfile`'s FROM statement has been updated with the newly built base Docker image automatically. This saves you from
|
37
|
+
Notice at the very end, the *current* `Dockerfile`'s FROM statement has been updated with the newly built base Docker image automatically. This saves you from forgetting to copying and pasting it the `Dockerfile` yourself.
|
38
38
|
|
39
|
-
<a id="prev" class="btn btn-basic" href="{% link _docs/ufo-docker-
|
39
|
+
<a id="prev" class="btn btn-basic" href="{% link _docs/ufo-docker-push.md %}">Back</a>
|
40
40
|
<a id="next" class="btn btn-primary" href="{% link _docs/ufo-docker-name.md %}">Next Step</a>
|
41
41
|
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
|
42
42
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
title: ufo docker build
|
3
3
|
---
|
4
4
|
|
5
|
-
The `ufo docker build` builds a Docker image using the Dockerfile in the current project folder. This simply a wrapper command that shells out and calls the `docker` command. We're use the [tongueroo/hi]((https://github.com/tongueroo/hi) project and it's Dockerfile for demonstration. Example:
|
5
|
+
The `ufo docker build` builds a Docker image using the Dockerfile in the current project folder. This simply is a wrapper command that shells out and calls the `docker` command. We're use the [tongueroo/hi]((https://github.com/tongueroo/hi) project and it's Dockerfile for demonstration. Example:
|
6
6
|
|
7
7
|
```sh
|
8
8
|
ufo docker build
|
@@ -71,9 +71,9 @@ ufo-2017-06-11T22-22-32-a18aa30: digest: sha256:c5385a5084e87643bd943eb120e11032
|
|
71
71
|
Pushed tongueroo/hi:ufo-2017-06-11T22-22-32-a18aa30 docker image. Took 9s.
|
72
72
|
```
|
73
73
|
|
74
|
-
Note in order to push the image to a
|
74
|
+
Note in order to push the image to a registry you will need to login into the registry. If you are using DockerHub use the `docker login` command. If you are using AWS ECR then you can use the `aws ecr get-login` command.
|
75
75
|
|
76
76
|
<a id="prev" class="btn btn-basic" href="{% link _docs/ufo-destroy.md %}">Back</a>
|
77
|
-
<a id="next" class="btn btn-primary" href="{% link _docs/ufo-docker-
|
77
|
+
<a id="next" class="btn btn-primary" href="{% link _docs/ufo-docker-push.md %}">Next Step</a>
|
78
78
|
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
|
79
79
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
title: ufo docker push
|
3
|
+
---
|
4
|
+
|
5
|
+
The `ufo docker push` command pushes the most recent Docker image built by `ufo docker build` to a registry. Example:
|
6
|
+
|
7
|
+
```sh
|
8
|
+
ufo docker build # to build the image
|
9
|
+
ufo docker name # to see the image name
|
10
|
+
ufo docker push # push up the registry
|
11
|
+
```
|
12
|
+
|
13
|
+
You'll see that `ufo docker push` simply shells out and calls `docker push`:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ ufo docker push
|
17
|
+
=> docker push 123456789.dkr.ecr.us-east-1.amazonaws.com/hi:ufo-2018-02-13T10-51-44-e0cc7be
|
18
|
+
The push refers to a repository [123456789.dkr.ecr.us-east-1.amazonaws.com/hi]
|
19
|
+
399c739c257d: Layer already exists
|
20
|
+
...
|
21
|
+
Pushed 123456789.dkr.ecr.us-east-1.amazonaws.com/hi:ufo-2018-02-13T10-51-44-e0cc7be docker image. Took 1s.
|
22
|
+
$
|
23
|
+
```
|
24
|
+
|
25
|
+
You can also specify your own custom image to push as a parameter.
|
26
|
+
|
27
|
+
```
|
28
|
+
ufo docker push my/image:tag
|
29
|
+
```
|
30
|
+
|
31
|
+
You could also use the `--push` flag as part of the `ufo docker build` command to achieve the same thing as `ufo docker push`. Some find that `ufo docker push` is more intutitive.
|
32
|
+
|
33
|
+
```sh
|
34
|
+
ufo docker build --push # same as above
|
35
|
+
```
|
36
|
+
|
37
|
+
## Docker Authorization
|
38
|
+
|
39
|
+
Note in order to push the image to a registry you will need to login into the registry. If you are using DockerHub use the `docker login` command. If you are using AWS ECR then, ufo will automatically try to authorize you and configure your `~/.docker/config.json`. If can also use `aws ecr get-login` command.
|
40
|
+
|
41
|
+
<a id="prev" class="btn btn-basic" href="{% link _docs/ufo-docker-build.md %}">Back</a>
|
42
|
+
<a id="next" class="btn btn-primary" href="{% link _docs/ufo-docker-base.md %}">Next Step</a>
|
43
|
+
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
|
data/docs/_docs/ufo-env.md
CHANGED
@@ -2,52 +2,54 @@
|
|
2
2
|
title: UFO_ENV
|
3
3
|
---
|
4
4
|
|
5
|
-
Ufo's behavior is controlled by the `UFO_ENV` environment variable. For example, the `UFO_ENV` variable is used to layer different ufo variable files together to make it easy to specify settings for different environments like production and
|
5
|
+
Ufo's behavior is controlled by the `UFO_ENV` environment variable. For example, the `UFO_ENV` variable is used to layer different ufo variable files together to make it easy to specify settings for different environments like production and development. This is covered thoroughly in the [Variables]({% link _docs/variables.md %}) section. `UFO_ENV` defaults to `development` when not set.
|
6
6
|
|
7
7
|
### Setting UFO_ENV
|
8
8
|
|
9
|
-
The `UFO_ENV` can be set
|
9
|
+
The `UFO_ENV` can be set in several ways:
|
10
10
|
|
11
11
|
1. At the CLI command invocation - This takes the highest precedence.
|
12
12
|
2. Exported as an environment variable to your shell - This takes the second highest precedence.
|
13
|
-
3.
|
13
|
+
3. From the `aws_profiles` setting in your `settings.yml` file - This takes the lowest precedence.
|
14
14
|
|
15
15
|
### At the CLI Command
|
16
16
|
|
17
17
|
```sh
|
18
|
-
|
18
|
+
ufo ship hi-web --cluster production
|
19
19
|
```
|
20
20
|
|
21
21
|
### As an environment variable
|
22
22
|
|
23
23
|
```sh
|
24
24
|
export UFO_ENV=production
|
25
|
-
ufo ship hi-web
|
25
|
+
ufo ship hi-web
|
26
26
|
```
|
27
27
|
|
28
28
|
Most people will set `UFO_ENV` in their `~/.profile`.
|
29
29
|
|
30
30
|
### In ufo/settings.yml
|
31
31
|
|
32
|
-
The most interesting way to set `UFO_ENV` is with the `
|
32
|
+
The most interesting way to set `UFO_ENV` is with the `aws_profiles` setting in `ufo/settings.yml`. Let's say you have a `~/.ufo/settings.yml` with the following:
|
33
33
|
|
34
34
|
```yaml
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
development:
|
36
|
+
aws_profiles:
|
37
|
+
- my-dev-profile
|
38
|
+
|
39
|
+
production:
|
40
|
+
aws_profiles:
|
41
|
+
- my-prod-profile
|
39
42
|
```
|
40
43
|
|
41
|
-
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 `
|
44
|
+
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_profiles` lookup. Example:
|
42
45
|
|
43
46
|
```sh
|
44
47
|
AWS_PROFILE=my-prod-profile => UFO_ENV=production
|
45
|
-
AWS_PROFILE=my-
|
46
|
-
AWS_PROFILE=
|
47
|
-
AWS_PROFILE=whatever => UFO_ENV=development
|
48
|
+
AWS_PROFILE=my-dev-profile => UFO_ENV=development
|
49
|
+
AWS_PROFILE=whatever => UFO_ENV=development # since there are no profiles that match
|
48
50
|
```
|
49
51
|
|
50
|
-
Notice how `AWS_PROFILE=whatever` results in `UFO_ENV=development`. This is because
|
52
|
+
Notice how `AWS_PROFILE=whatever` results in `UFO_ENV=development`. This is because there are not matching aws_profiles in the `settings.yml`. More info on settings is available at [settings]({% link _docs/settings.md %}).
|
51
53
|
|
52
54
|
<a id="prev" class="btn btn-basic" href="{% link _docs/settings.md %}">Back</a>
|
53
55
|
<a id="next" class="btn btn-primary" href="{% link _docs/variables.md %}">Next Step</a>
|