Skip to content

Commit 413bf98

Browse files
authored
Use more descriptive long-form options for curl, tar, and checksum validation (#6496)
1 parent ccc03f7 commit 413bf98

846 files changed

Lines changed: 2759 additions & 2717 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ The [`build-and-test.ps1`](https://github.com/dotnet/dotnet-docker/blob/main/bui
7575

7676
### Editing Dockerfiles
7777

78-
The [Dockerfiles](https://github.com/search?q=repo%3Adotnet%2Fdotnet-docker+path%3Asrc%2F**%2FDockerfile&type=code&ref=advsearch) contained in this repo are generated from a set of [Cottle](https://cottle.readthedocs.io/en/stable/page/01-overview.html) based [templates](https://github.com/dotnet/dotnet-docker/tree/main/eng/dockerfile-templates). A single template generates the set of Dockerfiles that are similar (e.g. all Windows sdk Dockerfiles for a particular .NET version). This ensures consistency across the various Dockerfiles and eases the burden of making changes to the Dockerfiles. Instead of editing the Dockerfiles directly, the templates should be updated and then the Dockerfiles should get regenerated by running the [generate Dockerfiles script](https://github.com/dotnet/dotnet-docker/blob/main/eng/dockerfile-templates/Get-GeneratedDockerfiles.ps1).
78+
The [Dockerfiles](https://github.com/search?q=repo%3Adotnet%2Fdotnet-docker+path%3Asrc%2F**%2FDockerfile&type=code&ref=advsearch) contained in this repo are generated from a set of [Cottle](https://cottle.readthedocs.io/en/stable/page/01-overview.html) based [templates](https://github.com/dotnet/dotnet-docker/tree/main/eng/dockerfile-templates). A single template generates the set of Dockerfiles that are similar (e.g. all Windows sdk Dockerfiles for a particular .NET version). This ensures consistency across the various Dockerfiles and eases the burden of making changes to the Dockerfiles. Instead of editing the Dockerfiles directly, the templates should be updated and then the Dockerfiles should get regenerated by running the [generate Dockerfiles script](https://github.com/dotnet/dotnet-docker/blob/main/eng/dockerfile-templates/Get-GeneratedDockerfiles.ps1).
79+
80+
#### Dockerfile style guide
81+
82+
Use the following formatting guidelines when authoring Dockerfiles in this repo:
83+
84+
- Separate instructions with an empty newline.
85+
- Separate stages with two empty newlines.
86+
- Prefer to use long-form command line options for better readability.
87+
- Leave an empty newline at the end of the Dockerfile.
7988

8089
### Editing READMEs
8190

eng/dockerfile-templates/Dockerfile.linux.download-file

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
set isAlpine to find(OS_VERSION, "alpine") >= 0 ^
1717
set shaFunction to ARGS["sha-function"] ^
1818
set shaFunction to when(shaFunction, shaFunction, "512")
19-
}}{{if isAlpine:wget {{headerArgs}}-O^else:curl {{headerArgs}}-fSL --output}} {{ARGS["out-file"]}} {{if isInternal:"{{ARGS["url"]}}"^else:{{ARGS["url"]}}}}{{if ARGS["sha"]: \
19+
}}{{if isAlpine:wget {{headerArgs}}--output-document^else:curl {{headerArgs}}--fail --show-error --location --output}} {{ARGS["out-file"]}} {{if isInternal:"{{ARGS["url"]}}"^else:{{ARGS["url"]}}}}{{if ARGS["sha"]: \
2020
&& {{ARGS["sha-var-name"]}}='{{ARGS["sha"]}}' \
2121
&& echo "${{ARGS["sha-var-name"]}} {{ARGS["out-file"]}}" | sha{{shaFunction}}sum -c -}}

eng/dockerfile-templates/Dockerfile.linux.extract-tarball

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
file: Tarball to extract
66
extract-paths: Paths within the tarball to extract
77
dest-dir: Destination directory
8-
}}tar -oxzf {{ARGS["file"]}}{{if ARGS["dest-dir"]: -C {{ARGS["dest-dir"]}}}}{{if ARGS["extract-paths"]: {{join(ARGS["extract-paths"], " ")}}}} \
8+
}}tar --gzip --extract --no-same-owner --file {{ARGS["file"]}}{{if ARGS["dest-dir"]: --directory {{ARGS["dest-dir"]}}}}{{if ARGS["extract-paths"]: {{join(ARGS["extract-paths"], " ")}}}} \
99
&& rm {{ARGS["file"]}}

eng/dockerfile-templates/Dockerfile.linux.install-files

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
set fileExtractionTemplate to when(ARGS["is-zip"], "Dockerfile.linux.extract-zip", "Dockerfile.linux.extract-tarball")
99
}}{{
1010
if ARGS["create-install-dir"]
11-
:mkdir -p {{ARGS["install-dir"]}} \
11+
:mkdir --parents {{ARGS["install-dir"]}} \
1212
}}{{
1313
for i, file in ARGS["files"]:{{
1414
if i > 0 || ARGS["create-install-dir"]:&& }}{{

eng/dockerfile-templates/Dockerfile.windows.extract-zip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
file: Zip to extract
66
extract-paths: Paths within the zip file to extract
77
dest-dir: Destination directory
8-
}}tar -oxzf {{ARGS["file"]}}{{if ARGS["dest-dir"]: -C {{ARGS["dest-dir"]}}}}{{if ARGS["extract-paths"]: {{join(ARGS["extract-paths"], " ")}}}}; `
8+
}}tar --gzip --extract --no-same-owner --file {{ARGS["file"]}}{{if ARGS["dest-dir"]: --directory {{ARGS["dest-dir"]}}}}{{if ARGS["extract-paths"]: {{join(ARGS["extract-paths"], " ")}}}}; `
99
Remove-Item -Force {{ARGS["file"]}}

eng/dockerfile-templates/runtime-deps/Dockerfile.chiseled-ubuntu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ RUN {{InsertTemplate("Dockerfile.linux.non-root-user-staged", [
8888
"create-home": "true"
8989
])}}
9090

91-
RUN mkdir -p /rootfs/var/lib/dpkg/ \
91+
RUN mkdir --parents /rootfs/var/lib/dpkg/ \
9292
&& chisel-wrapper --generate-dpkg-status /rootfs/var/lib/dpkg/status -- \
9393
--release ubuntu-{{osVersionNumber}} --root /rootfs \{{for index, pkg in pkgs:
9494
{{pkg}}{{if index < len(pkgs) - 1: \}}}}

eng/dockerfile-templates/runtime-deps/Dockerfile.distroless-mariner

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RUN mkdir {{distrolessStagingDir}} \
3434
COPY --from={{baseImage}} /var/lib/rpmmanifest/container-manifest-2 /tmp/rpmmanifest
3535
RUN tmpManifestPath="/tmp/rpmmanifest" \
3636
&& rpm --query --all --queryformat "%{NAME}\t%{VERSION}-%{RELEASE}\t%{INSTALLTIME}\t%{BUILDTIME}\t%{VENDOR}\t%{EPOCH}\t%{SIZE}\t%{ARCH}\t%{EPOCHNUM}\t%{SOURCERPM}\n" --root /staging | grep -v gpg-pubkey >> $tmpManifestPath \
37-
&& mkdir -p /staging/var/lib/rpmmanifest \
37+
&& mkdir --parents /staging/var/lib/rpmmanifest \
3838
# Remove duplicates that match on the first field (package name)
3939
&& tac $tmpManifestPath | gawk '!x[$1]++' | sort > /staging/var/lib/rpmmanifest/container-manifest-2
4040

@@ -49,12 +49,13 @@ RUN {{InsertTemplate("Dockerfile.linux.non-root-user-staged",
4949
])}}
5050

5151
# Clean up staging
52-
RUN rm -rf {{distrolessStagingDir}}/etc/tdnf \
53-
&& rm -rf {{distrolessStagingDir}}/run/* \
54-
&& rm -rf {{distrolessStagingDir}}/var/cache/tdnf \
55-
&& rm -rf {{distrolessStagingDir}}/var/lib/rpm \
56-
&& rm -rf {{distrolessStagingDir}}/usr/share/doc \
57-
&& rm -rf {{distrolessStagingDir}}/usr/share/man \
52+
RUN rm -rf \
53+
{{distrolessStagingDir}}/etc/tdnf \
54+
{{distrolessStagingDir}}/run/* \
55+
{{distrolessStagingDir}}/var/cache/tdnf \
56+
{{distrolessStagingDir}}/var/lib/rpm \
57+
{{distrolessStagingDir}}/usr/share/doc \
58+
{{distrolessStagingDir}}/usr/share/man \
5859
&& find {{distrolessStagingDir}}/var/log -type f -size +0 -delete
5960

6061

eng/dockerfile-templates/runtime-deps/Dockerfile.linux.non-root-user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
set addUserCommand to when(isAlpine,
2727
"adduser",
28-
"useradd -l") ^
28+
"useradd --no-log-init") ^
2929
set addUserGroupArg to when(isAlpine,
3030
cat("--ingroup=", name),
3131
cat("--gid=", gid)) ^

eng/dockerfile-templates/runtime-deps/Dockerfile.linux.non-root-user-staged

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"no-create-home": ARGS["no-create-home"],
2323
"no-shell": isDistroless
2424
])}} \{{if !ARGS["no-create-home"]:
25-
&& install -d -m 0755 -o {{uid}} -g {{gid}} "{{ARGS["staging-dir"]}}/home/{{ARGS["name"]}}" \}}{{if ARGS["create-dir"]:
26-
&& mkdir -p "{{ARGS["staging-dir"]}}/etc" \}}{{if ARGS["exclusive"]:
25+
&& install --directory --mode 0755 --owner {{uid}} --group {{gid}} "{{ARGS["staging-dir"]}}/home/{{ARGS["name"]}}" \}}{{if ARGS["create-dir"]:
26+
&& mkdir --parents "{{ARGS["staging-dir"]}}/etc" \}}{{if ARGS["exclusive"]:
2727
&& rootOrAppRegex='@^\(root\|app\):' \
2828
&& cat /etc/passwd | grep $rootOrAppRegex > "{{ARGS["staging-dir"]}}/etc/passwd" \
2929
&& cat /etc/group | grep $rootOrAppRegex > "{{ARGS["staging-dir"]}}/etc/group"^

eng/dockerfile-templates/sdk/Dockerfile.linux.install-powershell

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN powershell_version={{VARIABLES[cat("powershell|", dotnetVersion, "|build-ver
1414
"sha": VARIABLES[join(["powershell", dotnetVersion, shaPlatform, "sha"], "|")],
1515
"sha-var-name": "powershell_sha512"
1616
], " ")}} \
17-
&& mkdir -p /usr/share/powershell \
17+
&& mkdir --parents /usr/share/powershell \
1818
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.{{nupkgPlatform}} \
1919
&& dotnet nuget locals all --clear \
2020
&& rm {{nupkgName}} \

0 commit comments

Comments
 (0)