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
+70Lines changed: 70 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,4 +101,74 @@ 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
+
```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
+
104
174
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