Skip to content

Handle case where no shell is explicitly defined #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[#C285BF]FROM[/] [#96DCFE]scratch[/]
[#6D9A58]# No instruction info
[/][#C285BF]ARG[/] [green]EULA[/][#FAC81F]=[/][#96DCFE]@EULA_FILE@[/]
[#C285BF]COPY[/] [#96DCFE]EULA-Container.txt[/] [#96DCFE].[/] [#6D9A58]# buildkit
[/][#C285BF]CMD[/] [#FAC81F][[[/][#CA9178]"bash"[/][#FAC81F]]][/]
[#C285BF]ENV[/] [green]ASPNETCORE_URLS[/][#FAC81F]=[/][#96DCFE]http://+:80[/] [#FAC81F]\[/]
[green]DOTNET_RUNNING_IN_CONTAINER[/][#FAC81F]=[/][#96DCFE]true[/]
[#C285BF]RUN[/] [#96DCFE]/bin/sh -c tdnf install -y ca-certificates glibc icu krb5 libgcc libstdc++ openssl-libs zlib && tdnf clean all # buildkit
[/][#C285BF]RUN[/] [#96DCFE]/bin/sh -c dotnet_version=6.0.36 && curl -fSL --output dotnet-runtime-deps.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$dotnet_version/dotnet-runtime-deps-$dotnet_version-cm.2-x64.rpm && dotnet_sha512='c480ab7722f34eef1e0e55bf60b393cf6f4dc51ea78878b5a3b0e9c8c45d054d3c81b29a8783732c01ca62d3c5b6298a166a2de7c0e07f70067f22af375b6f1c' && echo "$dotnet_sha512 dotnet-runtime-deps.rpm" | sha512sum -c - && tdnf install -y --disablerepo=* dotnet-runtime-deps.rpm && rm dotnet-runtime-deps.rpm # buildkit
[/][#C285BF]ENV[/] [green]DOTNET_VERSION[/][#FAC81F]=[/][#96DCFE]6.0.36[/]
[#C285BF]RUN[/] [#96DCFE]/bin/sh -c curl -fSL --output dotnet-host.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-host-$DOTNET_VERSION-x64.rpm && dotnet_sha512='00d9f978054aef3ec4b2bd81eedee8184e4fd44eee364d82b81eab7079958a9d0fe6cfdf5f29c05f33a20e2cfc9761306a8bcc378dbc804cf1f38eb9ea29871e' && echo "$dotnet_sha512 dotnet-host.rpm" | sha512sum -c - && curl -fSL --output dotnet-hostfxr.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-hostfxr-$DOTNET_VERSION-x64.rpm && dotnet_sha512='79faa94cef34307a1d947300755e002056f42094003b3fc3447efea6731ddece3d6d18ab62c0292498418a627ba395c6c2053a8b92fbdac356cd0afb141e7e7d' && echo "$dotnet_sha512 dotnet-hostfxr.rpm" | sha512sum -c - && curl -fSL --output dotnet-runtime.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-x64.rpm && dotnet_sha512='a3a544b6d315daa8e4fceb75d7414502d5b8fa5c6f7dc14c5ea05a8c32d50adf8422471eac69893eb8ea10ff908879aea277fc2b6aa5a723b3f60cf3c2e84c7e' && echo "$dotnet_sha512 dotnet-runtime.rpm" | sha512sum -c - && tdnf install -y --disablerepo=* dotnet-host.rpm dotnet-hostfxr.rpm dotnet-runtime.rpm && rm dotnet-host.rpm dotnet-hostfxr.rpm dotnet-runtime.rpm # buildkit
[/]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[#C285BF]FROM[/] [#96DCFE]scratch[/]
[#6D9A58]# No instruction info
[/][#C285BF]ARG[/] [green]EULA[/][#FAC81F]=[/][#96DCFE]@EULA_FILE@[/]
[#C285BF]COPY[/] [#96DCFE]EULA-Container.txt[/] [#96DCFE].[/] [#6D9A58]# buildkit
[/][#C285BF]CMD[/] [#FAC81F][[[/][#CA9178]"bash"[/][#FAC81F]]][/]
[#C285BF]ENV[/] [green]ASPNETCORE_URLS[/][#FAC81F]=[/][#96DCFE]http://+:80[/] [green]DOTNET_RUNNING_IN_CONTAINER[/][#FAC81F]=[/][#96DCFE]true[/]
[#C285BF]RUN[/] [#96DCFE]/bin/sh -c tdnf install -y ca-certificates glibc icu krb5 libgcc libstdc++ openssl-libs zlib && tdnf clean all # buildkit
[/][#C285BF]RUN[/] [#96DCFE]/bin/sh -c dotnet_version=6.0.36 && curl -fSL --output dotnet-runtime-deps.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$dotnet_version/dotnet-runtime-deps-$dotnet_version-cm.2-x64.rpm && dotnet_sha512='c480ab7722f34eef1e0e55bf60b393cf6f4dc51ea78878b5a3b0e9c8c45d054d3c81b29a8783732c01ca62d3c5b6298a166a2de7c0e07f70067f22af375b6f1c' && echo "$dotnet_sha512 dotnet-runtime-deps.rpm" | sha512sum -c - && tdnf install -y --disablerepo=* dotnet-runtime-deps.rpm && rm dotnet-runtime-deps.rpm # buildkit
[/][#C285BF]ENV[/] [green]DOTNET_VERSION[/][#FAC81F]=[/][#96DCFE]6.0.36[/]
[#C285BF]RUN[/] [#96DCFE]/bin/sh -c curl -fSL --output dotnet-host.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-host-$DOTNET_VERSION-x64.rpm && dotnet_sha512='00d9f978054aef3ec4b2bd81eedee8184e4fd44eee364d82b81eab7079958a9d0fe6cfdf5f29c05f33a20e2cfc9761306a8bcc378dbc804cf1f38eb9ea29871e' && echo "$dotnet_sha512 dotnet-host.rpm" | sha512sum -c - && curl -fSL --output dotnet-hostfxr.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-hostfxr-$DOTNET_VERSION-x64.rpm && dotnet_sha512='79faa94cef34307a1d947300755e002056f42094003b3fc3447efea6731ddece3d6d18ab62c0292498418a627ba395c6c2053a8b92fbdac356cd0afb141e7e7d' && echo "$dotnet_sha512 dotnet-hostfxr.rpm" | sha512sum -c - && curl -fSL --output dotnet-runtime.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-x64.rpm && dotnet_sha512='a3a544b6d315daa8e4fceb75d7414502d5b8fa5c6f7dc14c5ea05a8c32d50adf8422471eac69893eb8ea10ff908879aea277fc2b6aa5a723b3f60cf3c2e84c7e' && echo "$dotnet_sha512 dotnet-runtime.rpm" | sha512sum -c - && tdnf install -y --disablerepo=* dotnet-host.rpm dotnet-hostfxr.rpm dotnet-runtime.rpm && rm dotnet-host.rpm dotnet-hostfxr.rpm dotnet-runtime.rpm # buildkit
[/]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"__comment": "mcr.microsoft.com/dotnet/runtime@sha256:fc41073691b0e33a21de5ed4fd64f06bbc827031e975e7b317e0a4ced85a96ed",
"os": "linux",
"history": [
{
"created": "2024-12-08T04:27:33.807635718Z",
"comment": "Imported from -"
},
{
"created": "2024-12-08T04:27:42.708534541Z",
"created_by": "ARG EULA=@EULA_FILE@",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2024-12-08T04:27:42.708534541Z",
"created_by": "COPY EULA-Container.txt . # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2024-12-08T04:27:42.708534541Z",
"created_by": "CMD [\"bash\"]",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2024-12-11T20:31:20.806995463Z",
"created_by": "ENV ASPNETCORE_URLS=http://+:80 DOTNET_RUNNING_IN_CONTAINER=true",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2024-12-11T20:31:20.806995463Z",
"created_by": "RUN /bin/sh -c tdnf install -y ca-certificates glibc icu krb5 libgcc libstdc++ openssl-libs zlib \u0026\u0026 tdnf clean all # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2024-12-11T20:31:22.638464065Z",
"created_by": "RUN /bin/sh -c dotnet_version=6.0.36 \u0026\u0026 curl -fSL --output dotnet-runtime-deps.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$dotnet_version/dotnet-runtime-deps-$dotnet_version-cm.2-x64.rpm \u0026\u0026 dotnet_sha512='c480ab7722f34eef1e0e55bf60b393cf6f4dc51ea78878b5a3b0e9c8c45d054d3c81b29a8783732c01ca62d3c5b6298a166a2de7c0e07f70067f22af375b6f1c' \u0026\u0026 echo \"$dotnet_sha512 dotnet-runtime-deps.rpm\" | sha512sum -c - \u0026\u0026 tdnf install -y --disablerepo=* dotnet-runtime-deps.rpm \u0026\u0026 rm dotnet-runtime-deps.rpm # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2024-12-11T20:31:29.473616568Z",
"created_by": "ENV DOTNET_VERSION=6.0.36",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2024-12-11T20:31:29.473616568Z",
"created_by": "RUN /bin/sh -c curl -fSL --output dotnet-host.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-host-$DOTNET_VERSION-x64.rpm \u0026\u0026 dotnet_sha512='00d9f978054aef3ec4b2bd81eedee8184e4fd44eee364d82b81eab7079958a9d0fe6cfdf5f29c05f33a20e2cfc9761306a8bcc378dbc804cf1f38eb9ea29871e' \u0026\u0026 echo \"$dotnet_sha512 dotnet-host.rpm\" | sha512sum -c - \u0026\u0026 curl -fSL --output dotnet-hostfxr.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-hostfxr-$DOTNET_VERSION-x64.rpm \u0026\u0026 dotnet_sha512='79faa94cef34307a1d947300755e002056f42094003b3fc3447efea6731ddece3d6d18ab62c0292498418a627ba395c6c2053a8b92fbdac356cd0afb141e7e7d' \u0026\u0026 echo \"$dotnet_sha512 dotnet-hostfxr.rpm\" | sha512sum -c - \u0026\u0026 curl -fSL --output dotnet-runtime.rpm https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-x64.rpm \u0026\u0026 dotnet_sha512='a3a544b6d315daa8e4fceb75d7414502d5b8fa5c6f7dc14c5ea05a8c32d50adf8422471eac69893eb8ea10ff908879aea277fc2b6aa5a723b3f60cf3c2e84c7e' \u0026\u0026 echo \"$dotnet_sha512 dotnet-runtime.rpm\" | sha512sum -c - \u0026\u0026 tdnf install -y --disablerepo=* dotnet-host.rpm dotnet-hostfxr.rpm dotnet-runtime.rpm \u0026\u0026 rm dotnet-host.rpm dotnet-hostfxr.rpm dotnet-runtime.rpm # buildkit",
"comment": "buildkit.dockerfile.v0"
}
]
}
9 changes: 9 additions & 0 deletions src/Valleysoft.Dredge.Tests/Valleysoft.Dredge.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
<None Update="TestData\DockerfileCommand\fedora\image.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\DockerfileCommand\mariner\expected-output-format.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\DockerfileCommand\mariner\expected-output-no-format.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\DockerfileCommand\mariner\image.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\DockerfileCommand\openjdk\expected-output-format.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
11 changes: 7 additions & 4 deletions src/Valleysoft.Dredge/Commands/Image/DockerfileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,14 @@ private string GetHistoryLine(string line, ref string? currentShell)
const string NopMarker = "#(nop)";

int nopIndex = line.IndexOf(NopMarker);
if (nopIndex >= 0)
if (nopIndex >= 0 || currentShell is null)
{
currentShell ??= line[0..nopIndex].Trim();

line = line[(nopIndex + NopMarker.Length)..].Trim();
if (nopIndex >= 0)
{
currentShell ??= line[0..nopIndex].Trim();
line = line[(nopIndex + NopMarker.Length)..].Trim();
}

if (line.StartsWith("ADD", StringComparison.OrdinalIgnoreCase) ||
line.StartsWith("COPY", StringComparison.OrdinalIgnoreCase))
{
Expand Down
Loading