Skip to content

Commit 6c99271

Browse files
authored
Merge pull request #3904 from arturcic/feature/docker-annotations
(build) Add docker image annotations
2 parents 4c9bd7c + bd89814 commit 6c99271

File tree

14 files changed

+399
-52
lines changed

14 files changed

+399
-52
lines changed

.github/actions/docker-publish/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ runs:
3535
-
3636
name: '[Docker Publish] DockerHub'
3737
shell: pwsh
38-
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry dockerhub
38+
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry dockerhub --verbosity=diagnostic
3939
-
4040
name: Login to GitHub
4141
uses: docker/login-action@v2
@@ -46,4 +46,4 @@ runs:
4646
-
4747
name: '[Docker Publish] GitHub'
4848
shell: pwsh
49-
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry github
49+
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry github --verbosity=diagnostic

.github/actions/docker-test/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ runs:
1717
-
1818
name: '[Docker Build & Test] DockerHub'
1919
shell: pwsh
20-
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry dockerhub
20+
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry dockerhub --verbosity=diagnostic
2121
-
2222
name: '[Docker Build & Test] GitHub'
2323
shell: pwsh
24-
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry github
24+
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry github --verbosity=diagnostic

.github/workflows/_docker.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ jobs:
3737
with:
3838
name: nuget
3939
path: ${{ github.workspace }}/artifacts/packages/nuget
40+
-
41+
name: Set up Docker
42+
uses: crazy-max/ghaction-setup-docker@v3
43+
with:
44+
daemon-config: '{ "features": { "containerd-snapshotter": true } }'
4045
-
4146
name: Setup QEMU
42-
if: inputs.arch == 'arm64'
4347
uses: docker/setup-qemu-action@v3
4448
-
4549
name: Setup Docker Buildx
46-
if: inputs.arch == 'arm64'
4750
uses: docker/setup-buildx-action@v3
4851
with:
49-
install: true
52+
version: 'latest'
53+
driver-opts: 'image=moby/buildkit:buildx-stable-1'
54+
install: true
5055
-
5156
name: Docker Test
5257
if: success() && github.event_name == 'pull_request' || github.repository_owner != 'GitTools'

.github/workflows/_docker_manifests.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ jobs:
2424
-
2525
name: Restore State
2626
uses: ./.github/actions/artifacts-restore
27+
-
28+
name: Set up Docker
29+
uses: crazy-max/ghaction-setup-docker@v3
30+
with:
31+
daemon-config: '{ "features": { "containerd-snapshotter": true } }'
32+
-
33+
name: Setup QEMU
34+
uses: docker/setup-qemu-action@v3
35+
-
36+
name: Setup Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
with:
39+
version: 'latest'
40+
driver-opts: 'image=moby/buildkit:buildx-stable-1'
41+
install: true
2742
-
2843
name: Docker Manifests
2944
if: success() && github.event_name != 'pull_request' && github.repository_owner == 'GitTools' && github.ref_name == 'main'

build/.run/Docker Build.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Docker Build" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=DockerBuild --arch=amd64 --docker_dotnetversion=6.0 --docker_distro=debian.11" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=DockerBuild --arch=amd64 --arch=arm64 --docker_dotnetversion=8.0 --docker_distro=debian.11 --verbosity=diagnostic" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/.run/Docker Manifest.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Docker Manifest" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=DockerManifest --arch=amd64 --arch=arm64 --docker_dotnetversion=6.0 --docker_distro=debian.11" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=DockerManifest --arch=amd64 --arch=arm64 --docker_dotnetversion=8.0 --docker_distro=debian.11" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/.run/Docker Publish.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Docker Publish" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=DockerPublish --arch=amd64 --docker_dotnetversion=6.0 --docker_distro=debian.11" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=DockerPublish --arch=amd64 --arch=arm64 --docker_dotnetversion=8.0 --docker_distro=debian.11 --verbosity=diagnostic" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/.run/Docker Test.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Docker Test" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=DockerTest --arch=amd64 --docker_dotnetversion=6.0 --docker_distro=debian.11" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=DockerTest --arch=amd64 --docker_dotnetversion=8.0 --docker_distro=debian.11" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Common.Addins.Cake.Docker;
2+
3+
/// <summary>
4+
/// Constants
5+
/// </summary>
6+
public static class Constants
7+
{
8+
/// <summary>
9+
/// Used with <see cref="AutoPropertyAttribute.Format"/> when a bool argument defaults to true.
10+
/// </summary>
11+
public const string BoolWithTrueDefaultFormat = "--{0}={1}";
12+
}
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
#nullable disable
2+
namespace Common.Addins.Cake.Docker;
3+
4+
/// <summary>
5+
/// Settings for docker buildx build.
6+
/// </summary>
7+
public sealed class DockerBuildXBuildSettings : AutoToolSettings
8+
{
9+
/// <summary>
10+
/// Add a custom host-to-IP mapping (format: "host:ip")
11+
/// </summary>
12+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
13+
public string[] AddHost { get; set; }
14+
/// <summary>
15+
/// Allow extra privileged entitlement (e.g., "network.host", "security.insecure")
16+
/// </summary>
17+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
18+
public string[] Allow { get; set; }
19+
/// <summary>
20+
/// Set build-time variables
21+
/// </summary>
22+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
23+
public string[] BuildArg { get; set; }
24+
/// <summary>
25+
/// Additional build contexts (e.g., name=path)
26+
/// </summary>
27+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
28+
public string[] BuildContext { get; set; }
29+
/// <summary>
30+
/// Override the configured builder instance
31+
/// </summary>
32+
public string Builder { get; set; }
33+
/// <summary>
34+
/// External cache sources (e.g., "user/app:cache", "type=local,src=path/to/dir")
35+
/// </summary>
36+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
37+
public string[] CacheFrom { get; set; }
38+
/// <summary>
39+
/// Cache export destinations (e.g., "user/app:cache", "type=local,dest=path/to/dir")
40+
/// </summary>
41+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
42+
public string[] CacheTo { get; set; }
43+
/// <summary>
44+
/// Optional parent cgroup for the container
45+
/// </summary>
46+
public string CgroupParent { get; set; }
47+
/// <summary>
48+
/// Compress the build context using gzip
49+
/// </summary>
50+
public bool? Compress { get; set; }
51+
/// <summary>
52+
/// Limit the CPU CFS (Completely Fair Scheduler) period
53+
/// </summary>
54+
public long? CpuPeriod { get; set; }
55+
/// <summary>
56+
/// Limit the CPU CFS (Completely Fair Scheduler) quota
57+
/// </summary>
58+
public long? CpuQuota { get; set; }
59+
/// <summary>
60+
/// CPUs in which to allow execution (0-3, 0,1)
61+
/// </summary>
62+
public string CpusetCpus { get; set; }
63+
/// <summary>
64+
/// MEMs in which to allow execution (0-3, 0,1)
65+
/// </summary>
66+
public string CpusetMems { get; set; }
67+
/// <summary>
68+
/// CPU shares (relative weight)
69+
/// </summary>
70+
public long? CpuShares { get; set; }
71+
/// <summary>
72+
/// Skip image verification
73+
/// </summary>
74+
[AutoProperty(Format = Constants.BoolWithTrueDefaultFormat)]
75+
public bool? DisableContentTrust { get; set; }
76+
/// <summary>
77+
/// Name of the Dockerfile (default: "PATH/Dockerfile")
78+
/// </summary>
79+
public string File { get; set; }
80+
/// <summary>
81+
/// Always remove intermediate containers
82+
/// </summary>
83+
public bool? ForceRm { get; set; }
84+
/// <summary>
85+
/// Write the image ID to the file
86+
/// </summary>
87+
public string Iidfile { get; set; }
88+
/// <summary>
89+
/// Container isolation technology
90+
/// </summary>
91+
public string Isolation { get; set; }
92+
/// <summary>
93+
/// Set metadata for an image
94+
/// </summary>
95+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
96+
public string[] Label { get; set; }
97+
/// <summary>
98+
/// Shorthand for "--output=type=docker"
99+
/// </summary>
100+
public bool Load { get; set; }
101+
/// <summary>
102+
/// Memory limit
103+
/// </summary>
104+
public string Memory { get; set; }
105+
/// <summary>
106+
/// Swap limit equal to memory plus swap: &#39;-1&#39; to enable unlimited swap
107+
/// </summary>
108+
public string MemorySwap { get; set; }
109+
/// <summary>
110+
/// Write build result metadata to the file
111+
/// </summary>
112+
public string MetadataFile { get; set; }
113+
/// <summary>
114+
/// Set the networking mode for the "RUN" instructions during build (default "default")
115+
/// </summary>
116+
public string Network { get; set; }
117+
/// <summary>
118+
/// Do not use cache when building the image
119+
/// </summary>
120+
public bool NoCache { get; set; }
121+
/// <summary>
122+
/// Do not cache specified stages
123+
/// </summary>
124+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
125+
public string[] NoCacheFilter { get; set; }
126+
/// <summary>
127+
/// Output destination (format: "type=local,dest=path")
128+
/// </summary>
129+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
130+
public string[] Output { get; set; }
131+
/// <summary>
132+
/// Set target platform for build
133+
/// </summary>
134+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
135+
public string[] Platform { get; set; }
136+
/// <summary>
137+
/// Set type of progress output ("auto", "plain", "tty"). Use plain to show container output (default "auto")
138+
/// </summary>
139+
public string Progress { get; set; }
140+
/// <summary>
141+
/// Always attempt to pull all referenced images
142+
/// </summary>
143+
public bool Pull { get; set; }
144+
/// <summary>
145+
/// Shorthand for "--output=type=registry"
146+
/// </summary>
147+
public bool Push { get; set; }
148+
/// <summary>
149+
/// Suppress the build output and print image ID on success
150+
/// </summary>
151+
public bool Quiet { get; set; }
152+
/// <summary>
153+
/// Remove intermediate containers after a successful build
154+
/// </summary>
155+
[AutoProperty(Format = Constants.BoolWithTrueDefaultFormat)]
156+
public bool? Rm { get; set; }
157+
/// <summary>
158+
/// Secret to expose to the build (format: "id=mysecret[,src=/local/secret]")
159+
/// </summary>
160+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
161+
public string[] Secret { get; set; }
162+
/// <summary>
163+
/// Security options
164+
/// </summary>
165+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
166+
public string[] SecurityOpt { get; set; }
167+
/// <summary>
168+
/// Size of "/dev/shm"
169+
/// </summary>
170+
public string ShmSize { get; set; }
171+
/// <summary>
172+
/// Squash newly built layers into a single new layer
173+
/// </summary>
174+
public bool? Squash { get; set; }
175+
/// <summary>
176+
/// SSH agent socket or keys to expose to the build (format: "default|&lt;id&gt;[=&lt;socket&gt;|&lt;key&gt;[,&lt;key&gt;]]")
177+
/// </summary>
178+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
179+
public string[] Ssh { get; set; }
180+
/// <summary>
181+
/// Name and optionally a tag (format: "name:tag")
182+
/// </summary>
183+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
184+
public string[] Tag { get; set; }
185+
/// <summary>
186+
/// Set the target build stage to build.
187+
/// </summary>
188+
public string Target { get; set; }
189+
/// <summary>
190+
/// Ulimit options (default [])
191+
/// </summary>
192+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
193+
public string[] Ulimit { get; set; }
194+
/// <summary>
195+
/// Set annotation for new image
196+
/// </summary>
197+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
198+
public string[] Annotation { get; set; }
199+
}

0 commit comments

Comments
 (0)