Skip to content

Commit f39d213

Browse files
committed
(build) updated docker image creation, include labels and annotations
1 parent 4c9bd7c commit f39d213

File tree

6 files changed

+368
-41
lines changed

6 files changed

+368
-41
lines changed
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+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#nullable disable
2+
namespace Common.Addins.Cake.Docker;
3+
4+
/// <summary>
5+
/// Settings for docker buildx imagetools create.
6+
/// </summary>
7+
public sealed class DockerBuildXImageToolsCreateSettings : AutoToolSettings
8+
{
9+
/// <summary>
10+
/// Append to existing manifest
11+
/// </summary>
12+
public bool Append { get; set; }
13+
/// <summary>
14+
/// Override the configured builder instance
15+
/// </summary>
16+
public string Builder { get; set; }
17+
/// <summary>
18+
/// Show final image instead of pushing
19+
/// </summary>
20+
public bool DryRun { get; set; }
21+
/// <summary>
22+
/// Read source descriptor from file
23+
/// </summary>
24+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
25+
public string[] File { get; set; }
26+
/// <summary>
27+
/// Set reference for new image
28+
/// </summary>
29+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
30+
public string[] Tag { get; set; }
31+
/// <summary>
32+
/// Set annotation for new image
33+
/// </summary>
34+
[AutoProperty(AutoArrayType = AutoArrayType.List)]
35+
public string[] Annotation { get; set; }
36+
}

0 commit comments

Comments
 (0)