Skip to content

Commit 8cddad6

Browse files
author
Martin Dekov (VMware)
committed
Document the new faas-cli --tag feature
Add to cli field in file build.md explanation to what the --tag feature does. Signed-off-by: Martin Dekov (VMware) <[email protected]>
1 parent 1810719 commit 8cddad6

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

docs/cli/build.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,74 @@ Remeber to add any `ARG` values to the template's Dockerfile:
101101
ARG ARGNAME2
102102
```
103103

104+
## 4.0 Personalize your image tags through ```--tag```
105+
106+
In one of our stack.yml files we have this block:
107+
```yaml
108+
...
109+
functions:
110+
example_name:
111+
lang: dockerfile
112+
handler: ./example_name
113+
image: example_name
114+
...
115+
```
116+
117+
We are concerned with `image: example_name` field and if we use:
118+
119+
```bash
120+
faas-cli build -f ./stack.yml
121+
faas-cli push -f ./stack.yml
122+
faas-cli deploy -f ./stack.yml
123+
docker image ls
124+
```
125+
126+
under TAG field we will see `latest` this is the default tag.
127+
128+
How to personalize that tag?
129+
130+
Well we just need to add `:example_tag` to the image name above so our field looks like that `image: example_name:example_tag`:
131+
132+
```yaml
133+
...
134+
functions:
135+
example_name:
136+
lang: dockerfile
137+
handler: ./example_name
138+
image: example_name:example_tag
139+
...
140+
```
141+
142+
```bash
143+
faas-cli build -f ./stack.yml
144+
faas-cli push -f ./stack.yml
145+
faas-cli deploy -f ./stack.yml
146+
docker image ls
147+
```
148+
149+
Now under TAG instead of `latest` we have `example_tag`.
150+
151+
To further personalize your naming every time you commit to github, your commit get unique sha which you can append to your TAG with the following command `--tag=sha` like so:
152+
153+
```bash
154+
faas-cli build -f ./stack.yml --tag=sha
155+
faas-cli push -f ./stack.yml --tag=sha
156+
faas-cli deploy -f ./stack.yml --tag=sha
157+
docker image ls
158+
```
159+
160+
Now under TAG will see `example_tag` changed with `example_tag-example_sha`
161+
162+
Now we want to extend this even further by adding the branch in which we commit so we swap `sha` with `branch`
163+
and it becomes `--tag=branch`:
164+
165+
```bash
166+
faas-cli build -f ./stack.yml --tag=branch
167+
faas-cli push -f ./stack.yml --tag=branch
168+
faas-cli deploy -f ./stack.yml --tag=branch
169+
docker image ls
170+
```
171+
172+
The TAG field will be named `example_tag-example_branch-example_sha`.
173+
104174
For more information about passing build arguments to Docker, please visit the [Docker documentation](https://docs.docker.com/engine/reference/commandline/build/)

0 commit comments

Comments
 (0)