Skip to content

Commit

Permalink
[Docker] Add Dockerfile links into Dockerhub documentation (#127)
Browse files Browse the repository at this point in the history
* Add template for the header @ README.md

* Add links to custom Docker images.

* * Implement method to add links for Dockerfiles automatically.
* Include it into the documentation.

* Update docstirngs.

* Increase the level of the header, moving it upward.
  • Loading branch information
AndreyKoltsov1997 authored Nov 24, 2023
1 parent 433e561 commit 52f757f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
7 changes: 7 additions & 0 deletions context/generated/teamcity-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Supported platforms: windows 1809, windows 2022
- [EAP-windowsservercore-2022](#EAP-windowsservercore-2022)


# Dockerfile links

* **Linux**. [teamcity-agent:EAP-linux,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/Ubuntu/20.04/Dockerfile), [teamcity-agent:EAP-linux-arm64,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/UbuntuARM/20.04/Dockerfile), [teamcity-agent:EAP-linux-arm64-sudo](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/UbuntuARM/20.04-sudo/Dockerfile), [teamcity-agent:EAP-linux-sudo](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/Ubuntu/20.04-sudo/Dockerfile), [teamcity-agent:EAP-linux-18.04,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/Ubuntu/18.04/Dockerfile), [teamcity-agent:EAP-linux-18.04-sudo](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/Ubuntu/18.04-sudo/Dockerfile), [teamcity-agent:EAP-linux-arm64-18.04,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/UbuntuARM/18.04/Dockerfile), [teamcity-agent:EAP-linux-arm64-18.04-sudo](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Agent/UbuntuARM/18.04-sudo/Dockerfile)

* **Windows**. [teamcity-agent:EAP-nanoserver-1809,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/nanoserver/1809/Dockerfile), [teamcity-agent:EAP-nanoserver-2022,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/nanoserver/2022/Dockerfile), [teamcity-agent:EAP-windowsservercore-1809,EAP-windowsservercore,-windowsservercore](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/windowsservercore/1809/Dockerfile), [teamcity-agent:EAP-windowsservercore-2022,EAP-windowsservercore,-windowsservercore](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/windowsservercore/2022/Dockerfile), [teamcity-agent:EAP-nanoserver-1803,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/nanoserver/1803/Dockerfile), [teamcity-agent:EAP-nanoserver-1903,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/nanoserver/1903/Dockerfile), [teamcity-agent:EAP-nanoserver-1909,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/nanoserver/1909/Dockerfile), [teamcity-agent:EAP-windowsservercore-1803,EAP-windowsservercore,-windowsservercore](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/windowsservercore/1803/Dockerfile), [teamcity-agent:EAP-windowsservercore-1903,EAP-windowsservercore,-windowsservercore](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/windowsservercore/1903/Dockerfile), [teamcity-agent:EAP-windowsservercore-1909,EAP-windowsservercore,-windowsservercore](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Agent/windowsservercore/1909/Dockerfile)


### EAP-linux

[Dockerfile](linux/Agent/Ubuntu/20.04/Dockerfile)
Expand Down
7 changes: 7 additions & 0 deletions context/generated/teamcity-minimal-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ Supported platforms: linux 20.04, windows 1809, windows 2022
- [EAP-nanoserver-2022](#EAP-nanoserver-2022)


# Dockerfile links

* **Linux**. [teamcity-minimal-agent:EAP-linux,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/MinimalAgent/Ubuntu/20.04/Dockerfile), [teamcity-minimal-agent:EAP-linux-18.04,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/MinimalAgent/Ubuntu/18.04/Dockerfile), [teamcity-minimal-agent:EAP-linux-arm64,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/MinimalAgent/UbuntuARM/20.04/Dockerfile), [teamcity-minimal-agent:EAP-linux-arm64-18.04,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/MinimalAgent/UbuntuARM/18.04/Dockerfile)

* **Windows**. [teamcity-minimal-agent:EAP-nanoserver-1809,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/MinimalAgent/nanoserver/1809/Dockerfile), [teamcity-minimal-agent:EAP-nanoserver-2022,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/MinimalAgent/nanoserver/2022/Dockerfile), [teamcity-minimal-agent:EAP-nanoserver-1803,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/MinimalAgent/nanoserver/1803/Dockerfile), [teamcity-minimal-agent:EAP-nanoserver-1903,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/MinimalAgent/nanoserver/1903/Dockerfile), [teamcity-minimal-agent:EAP-nanoserver-1909,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/MinimalAgent/nanoserver/1909/Dockerfile)


### EAP-linux

[Dockerfile](linux/MinimalAgent/Ubuntu/20.04/Dockerfile)
Expand Down
7 changes: 7 additions & 0 deletions context/generated/teamcity-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ Supported platforms: linux 20.04, windows 1809, windows 2022
- [EAP-nanoserver-2022](#EAP-nanoserver-2022)


# Dockerfile links

* **Linux**. [teamcity-server:EAP-linux,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Server/Ubuntu/20.04/Dockerfile), [teamcity-server:EAP-linux-18.04,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Server/Ubuntu/18.04/Dockerfile), [teamcity-server:EAP-linux-arm64,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Server/UbuntuARM/20.04/Dockerfile), [teamcity-server:EAP-linux-arm64-18.04,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/linux/Server/UbuntuARM/18.04/Dockerfile)

* **Windows**. [teamcity-server:EAP-nanoserver-1809,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Server/nanoserver/1809/Dockerfile), [teamcity-server:EAP-nanoserver-2022,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Server/nanoserver/2022/Dockerfile), [teamcity-server:EAP-nanoserver-1803,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Server/nanoserver/1803/Dockerfile), [teamcity-server:EAP-nanoserver-1903,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Server/nanoserver/1903/Dockerfile), [teamcity-server:EAP-nanoserver-1909,EAP](https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/windows/Server/nanoserver/1909/Dockerfile)


### EAP-linux

[Dockerfile](linux/Server/Ubuntu/20.04/Dockerfile)
Expand Down
13 changes: 8 additions & 5 deletions dockerhub/teamcity-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ docker run -e SERVER_URL="<url to TeamCity server>" \
-v <path to agent config folder>:/data/teamcity_agent/conf \
-v docker_volumes:/var/lib/docker \
--privileged -e DOCKER_IN_DOCKER=start \
jetbrains/teamcity-agent:2021.1.1-linux-sudo
jetbrains/teamcity-agent:2023.11-linux-sudo
```

The option `-v docker_volumes:/var/lib/docker` is related to the case when the `aufs` filesystem is used and when a build agent is started from a Windows machine ([related issue](https://youtrack.jetbrains.com/issue/TW-52939)).
Expand All @@ -130,12 +130,14 @@ If you want to start several build agents, you need to specify different volumes
### Windows Containers Limitations

The details on the known problems in Windows containers are available in the [TeamCity documentation](https://www.jetbrains.com/help/teamcity/known-issues.html#KnownIssues-WindowsDockerContainers).

## Customization

You can customize the image via the usual Docker procedure:
**Leveraging existing Dockerfiles**. Please, refer to [custom TeamCity Agent Images for more information](https://github.com/JetBrains/teamcity-docker-images/tree/master/custom).

**Manually**. To customise the Agent image manually, please follow the procedure below.

1. Run the image
1. Create a container.
```
docker run -e SERVER_URL="<url to TeamCity server>" \
-v <path to agent config folder>:/data/teamcity_agent/conf \
Expand All @@ -146,13 +148,14 @@ docker run -e SERVER_URL="<url to TeamCity server>" \
```
docker exec -it my-customized-agent bash
```
3. Change whatever you need
3. Please make any required adjustments as needed

4. Exit and [create a new image](https://docs.docker.com/engine/reference/commandline/commit/) from the container:
```
docker commit my-customized-agent <the registry where you what to store the image>
```


## License

The image is available under the [TeamCity license](https://www.jetbrains.com/teamcity/buy/license.html).
Expand Down
7 changes: 4 additions & 3 deletions dockerhub/teamcity-minimal-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ The details on the known problems in Windows containers are available in the [Te

## Customization

You can customize the image via the usual Docker procedure:
**Leveraging existing Dockerfiles**. Please, refer to [custom TeamCity Agent Images for more information](https://github.com/JetBrains/teamcity-docker-images/tree/master/custom).

**Manually**. To customise the Agent image manually, please follow the procedure below.

1. Run the image
```
Expand All @@ -72,8 +74,7 @@ docker run -e SERVER_URL="<url to TeamCity server>" \
```
docker exec -it my-customized-agent bash
```

3. Change whatever you need
3. Please make any required adjustments as needed
4. Exit and [create a new image](https://docs.docker.com/engine/reference/commandline/commit/) from the container
```
docker commit my-customized-agent <the registry where you what to store the image>
Expand Down
23 changes: 22 additions & 1 deletion tool/TeamCity.Docker/ReadmeFilesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace TeamCity.Docker
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Generic;
using IoC;
using Model;
Expand Down Expand Up @@ -142,7 +143,12 @@ orderby image.Key.Description descending

lines.Add(string.Empty);
}


// Adding Dockerfile links
lines.Add(string.Empty);
lines.Add("# Dockerfile links\n");
lines.Add(GetLinkForOs(groupByImage, "Linux"));
lines.Add(GetLinkForOs(groupByImage, "Windows"));
lines.Add(string.Empty);

foreach (var groupByFile in groupByImage)
Expand Down Expand Up @@ -228,6 +234,21 @@ orderby image.Key.Description descending
}
}

/// <summary>
/// Returns documentation string indicating existing Dockerfile links.
/// </summary>
/// <param name="imageNodes">list containing grouping of target Docker Images (Dockerfile, name, ID, etc.)</param>
/// <param name="osIdentifier">ID of the OS (Windows / Linux)</param>
/// <returns>documentation line with the links to given Dockerfiles</returns>
private string GetLinkForOs(List<IGrouping<Dockerfile, INode<IArtifact>>> imageNodes, string osIdentifier)
{
string urlPrefix = "https://github.com/JetBrains/teamcity-docker-images/tree/master/context/generated/";
string osLinks = string.Join(", ", imageNodes
.Where(obj => _pathService.Normalize(Path.Combine(obj.Key.Path, "Dockerfile")).Contains(osIdentifier, StringComparison.OrdinalIgnoreCase))
.Select(obj => $"[{obj.Key}]({urlPrefix}{_pathService.Normalize(Path.Combine(obj.Key.Path, "Dockerfile"))})"));
return $"* **{osIdentifier}**. {osLinks}\n";
}

private string GetReadmeFile(string imageId)
{
return _pathService.Normalize(Path.Combine(_options.TargetPath, GetReadmeFilePath(imageId)));
Expand Down

0 comments on commit 52f757f

Please sign in to comment.