You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cli/build.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,4 +101,75 @@ Remeber to add any `ARG` values to the template's Dockerfile:
101
101
ARG ARGNAME2
102
102
```
103
103
104
+
## 4.0 Personalize your image tags through ```--tag```
105
+
106
+
In one of our stack.yml files we have this block:
107
+
108
+
```yaml
109
+
...
110
+
functions:
111
+
example_name:
112
+
lang: dockerfile
113
+
handler: ./example_name
114
+
image: example_name
115
+
...
116
+
```
117
+
118
+
We are concerned with `image: example_name` field and if we use:
119
+
120
+
```bash
121
+
faas-cli build -f ./stack.yml
122
+
faas-cli push -f ./stack.yml
123
+
faas-cli deploy -f ./stack.yml
124
+
docker image ls
125
+
```
126
+
127
+
under TAG field we will see `latest` this is the default tag.
128
+
129
+
How to personalize that tag?
130
+
131
+
Well we just need to add `:example_tag` to the image name above so our field looks like that `image: example_name:example_tag`:
132
+
133
+
```yaml
134
+
...
135
+
functions:
136
+
example_name:
137
+
lang: dockerfile
138
+
handler: ./example_name
139
+
image: example_name:example_tag
140
+
...
141
+
```
142
+
143
+
```bash
144
+
faas-cli build -f ./stack.yml
145
+
faas-cli push -f ./stack.yml
146
+
faas-cli deploy -f ./stack.yml
147
+
docker image ls
148
+
```
149
+
150
+
Now under TAG instead of `latest` we have `example_tag`.
151
+
152
+
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:
153
+
154
+
```bash
155
+
faas-cli build -f ./stack.yml --tag=sha
156
+
faas-cli push -f ./stack.yml --tag=sha
157
+
faas-cli deploy -f ./stack.yml --tag=sha
158
+
docker image ls
159
+
```
160
+
161
+
Now under TAG will see `example_tag` changed with `example_tag-example_sha`
162
+
163
+
Now we want to extend this even further by adding the branch in which we commit so we swap `sha` with `branch`
164
+
and it becomes `--tag=branch`:
165
+
166
+
```bash
167
+
faas-cli build -f ./stack.yml --tag=branch
168
+
faas-cli push -f ./stack.yml --tag=branch
169
+
faas-cli deploy -f ./stack.yml --tag=branch
170
+
docker image ls
171
+
```
172
+
173
+
The TAG field will be named `example_tag-example_branch-example_sha`.
174
+
104
175
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