Skip to content

Commit 9d7452d

Browse files
committed
#4078 - update dockerhub README info
1 parent be9ccda commit 9d7452d

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed

build/common/Utilities/DockerContextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private static IEnumerable<string> GetDockerTags(this BuildContextBase context,
202202
var distro = dockerImage.Distro;
203203
var targetFramework = dockerImage.TargetFramework;
204204

205-
if (context.Version == null) return Enumerable.Empty<string>();
205+
if (context.Version == null) return [];
206206
var tags = new List<string>
207207
{
208208
$"{name}:{context.Version.Version}-{distro}-{targetFramework}",

build/docker/Tasks/DockerHubReadmePublish.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private static string GetReadmeContent(BuildContextBase context)
5555
// language=markdown
5656
var readme = $"""
5757
# GitVersion
58+
5859
![GitVersion – From git log to SemVer in no time][banner]
5960
6061
Versioning when using Git, solved. GitVersion looks at your git history and works out the [Semantic Version][semver] of the commit being built.
@@ -63,18 +64,35 @@ private static string GetReadmeContent(BuildContextBase context)
6364
6465
## Usage
6566
66-
The recommended image to run is `alpine`, as they are the smallest Docker images we provide (83 MB). This will execute GitVersion for the current working directory (`$(pwd)`) on Linux and Unix or powershell on Windows:
67+
The recommended image to run is `alpine`, as they are the smallest Docker images we provide. This will execute GitVersion for the current working directory (`$(pwd)`) on Linux and Unix or powershell on Windows:
6768
6869
```sh
6970
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag} /repo
7071
```
72+
7173
The following command will execute GitVersion for the current working directory (`%CD%`) on Windows with CMD:
7274
7375
```sh
7476
docker run --rm -v "%CD%:/repo" gittools/gitversion:{tag} /repo
7577
```
78+
7679
Note that the path `/repo` needs to be passed as an argument since the `gitversion` executable within the container is not aware of the fact that it's running inside a container.
7780
81+
### CI Agents
82+
83+
If you are running GitVersion on a CI agent, you may need to specify environment variables to allow GitVersion to work correctly.
84+
For example, on Azure DevOps you may need to set the following environment variables:
85+
86+
```sh
87+
docker run --rm -v "$(pwd):/repo" --env TF_BUILD=true --env BUILD_SOURCEBRANCH=$(Build.SourceBranch) gittools/gitversion:{tag} /repo
88+
```
89+
90+
On GitHub Actions, you may need to set the following environment variables:
91+
92+
```sh
93+
docker run --rm -v "$(pwd):/repo" --env GITHUB_ACTIONS=true --env GITHUB_REF=$(GITHUB_REF) gittools/gitversion:{tag} /repo
94+
```
95+
7896
### Tags
7997
8098
Most of the tags we provide have both arm64 and amd64 variants. If you need to pull a architecture specific tag you can do that like:

docs/input/docs/usage/docker.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,45 @@ Description: |
55
Use GitVersion through one of its many published Docker containers.
66
---
77

8-
GitVersion can be used through one of its many published Docker
9-
containers. The list of available containers can be found on
10-
[Docker Hub][docker-hub]. Once you've found the image you want to use,
11-
you can run it like this:
8+
The recommended image to run is `alpine`, as they are the smallest Docker images we provide. This will execute GitVersion for the current working directory (`$(pwd)`) on Linux and Unix or powershell on Windows:
129

13-
```shell
14-
docker run --rm --volume "$(pwd):/repo" gittools/gitversion:6.0.0-fedora.36-6.0 /repo
10+
```sh
11+
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag} /repo
1512
```
1613

17-
The above command will run GitVersion with the current directory
18-
mapped to `/repo` inside the container (the `--volume "$(pwd):/repo"`
19-
part). The `/repo` directory is then passed in as the argument
20-
GitVersion should use to calculate the version.
14+
The following command will execute GitVersion for the current working directory (`%CD%`) on Windows with CMD:
2115

22-
The `--rm` flag will remove the container after it has finished
23-
running.
16+
```sh
17+
docker run --rm -v "%CD%:/repo" gittools/gitversion:{tag} /repo
18+
```
19+
20+
Note that the path `/repo` needs to be passed as an argument since the `gitversion` executable within the container is not aware of the fact that it's running inside a container.
21+
22+
### CI Agents
23+
24+
If you are running GitVersion on a CI agent, you may need to specify environment variables to allow GitVersion to work correctly.
25+
For example, on Azure DevOps you may need to set the following environment variables:
26+
27+
```sh
28+
docker run --rm -v "$(pwd):/repo" --env TF_BUILD=true --env BUILD_SOURCEBRANCH=$(Build.SourceBranch) gittools/gitversion:{tag} /repo
29+
```
30+
31+
On GitHub Actions, you may need to set the following environment variables:
32+
33+
```sh
34+
docker run --rm -v "$(pwd):/repo" --env GITHUB_ACTIONS=true --env GITHUB_REF=$(GITHUB_REF) gittools/gitversion:{tag} /repo
35+
```
36+
37+
### Tags
38+
39+
Most of the tags we provide have both arm64 and amd64 variants. If you need to pull a architecture specific tag you can do that like:
40+
41+
```sh
42+
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag}-amd64 /repo
43+
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag}-arm64 /repo
44+
```
45+
46+
The list of available containers can be found on [Docker Hub][docker-hub].
2447

2548
[Explore GitVersion on Docker Hub][docker-hub]{.btn .btn-primary}
2649

0 commit comments

Comments
 (0)