Skip to content

Commit 34c42cd

Browse files
committed
Add tag documentation
- --tag was added to the CLI for build/push/deploy, this change takes inspiration from #50 via @MrTinD and closes #49. Signed-off-by: Alex Ellis (VMware) <[email protected]>
1 parent 1810719 commit 34c42cd

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

docs/cli/tags.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Working with tags
2+
3+
All OpenFaaS functions are built into immutable Docker images before deployment. You can take advantage of Docker "tags" to organise your versions the CLI can also generate tags based upon Git metadata.
4+
5+
## Option 1 - YAML file
6+
7+
You can define your tag in the stack YAML file. By default this tag is ":latest"
8+
9+
```
10+
image: my-fn
11+
```
12+
13+
or
14+
15+
16+
```
17+
image: my-fn:latest
18+
```
19+
20+
## Option 2 - `--tag` option
21+
22+
The `--tag` option works with the `faas-cli` sub-commands: `build`, `push` and `deploy`.
23+
24+
When using a --tag feature which relies on metadata from a Git commit then the build, push and deploy commands must be run pointing at the same Git commit.
25+
26+
Example usage:
27+
28+
```
29+
faas-cli build --tag=sha|branch
30+
faas-cli push --tag=sha|branch
31+
faas-cli deploy --tag=sha|branch
32+
```
33+
34+
There are currently two formats for "automatic tags".
35+
36+
### 2.1 Use the SHA (`--tag=sha`)
37+
38+
In this example whatever tag is defined in your YAML file (or latest, if not is given) will be suffixed with "-" plus the short Git SHA. A Git repository will be required to use this feature.
39+
40+
Example:
41+
42+
```
43+
image: my-fn:0.2
44+
45+
image: my-other-fn
46+
```
47+
48+
Gives the equivalent:
49+
50+
51+
```
52+
image: my-fn:0.2-cf59cfc
53+
54+
image: my-other-fn:latest-cf59cfc
55+
```
56+
57+
### 2.2 Use the SHA plus the branch (`--tag=branch`)
58+
59+
In this example you will get an output which includes the SHA and the branch name. This is useful for promotion code through enviroments with a continuous delivery tool. If you use one branch per environment in Git then the tool can parse the tag and match it to an environment.
60+
61+
62+
Example:
63+
64+
(on the master branch)
65+
66+
```
67+
image: my-fn:0.2
68+
```
69+
70+
Gives the equivalent:
71+
72+
```
73+
image: my-fn:0.2-master-cf59cfc
74+
```
75+
76+
(on the staging branch)
77+
78+
```
79+
image: my-fn:0.2-staging-cf59cfc
80+
```
81+

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pages:
116116
- Installation: ./cli/install.md
117117
- Create functions: ./cli/templates.md
118118
- Build functions: ./cli/build.md
119+
- Working with tags: ./cli/tags.md
119120
- Tutorials:
120121
- CLI with Node.js: ./tutorials/CLI-with-node.md
121122
- First Python Function: ./tutorials/first-python-function.md

0 commit comments

Comments
 (0)