Skip to content
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
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
<PackageReference Include="Scriban.Signed" Version="5.5.2" />
<PackageReference Include="Scriban.Signed" Version="7.2.0" />
Comment thread
VindhyaP312 marked this conversation as resolved.
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
<PackageReference Include="YamlDotNet" Version="12.3.1" />
</ItemGroup>
Expand Down
30 changes: 30 additions & 0 deletions images/build/Dockerfiles/oryxTools.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Oryx Tools - Volume Mount Image
# Packages Oryx build system binaries into a minimal filesystem-only image.
# The image is mounted at /opt/oryx inside Kudu containers at runtime.

ARG BASE_IMAGE
Comment thread
VindhyaP312 marked this conversation as resolved.

FROM ${BASE_IMAGE} AS source

ARG GIT_COMMIT=unspecified
ARG BUILD_NUMBER=unspecified
ARG RELEASE_TAG_NAME=unspecified

# Signed oryx binaries produced by the pipeline build step
COPY binaries /opt/oryx/

# Helper scripts renamed into place
COPY images/build/benv.sh /opt/oryx/benv
COPY images/build/logger.sh /opt/oryx/logger

# Rename main binary, set permissions, write image markers
RUN mv /opt/oryx/GenerateBuildScript /opt/oryx/oryx \
&& chmod a+x /opt/oryx/oryx \
&& chmod a+x /opt/oryx/Microsoft.Oryx.BuildServer \
&& chmod +x /opt/oryx/benv \
&& chmod +x /opt/oryx/logger \
&& echo "volume-mount" > /opt/oryx/.imagetype
Comment thread
VindhyaP312 marked this conversation as resolved.

FROM scratch

COPY --from=source /opt/oryx/ /
17 changes: 12 additions & 5 deletions src/BuildScriptGenerator/BaseBashBuildScript.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,20 @@ echo "Manifest file created."
{{ end }}
{{ end }}

OS_TYPE_SOURCE_DIR="/opt/oryx/.ostype"
if [ -f "$OS_TYPE_SOURCE_DIR" ]
if [ -n "$DEBIAN_FLAVOR" ]
then
echo "Copying .ostype to manifest output directory."
cp "$OS_TYPE_SOURCE_DIR" "$MANIFEST_DIR/.ostype"
echo "Generating .ostype from DEBIAN_FLAVOR environment variable."
echo "DEBIAN|$DEBIAN_FLAVOR" | tr '[a-z]' '[A-Z]' > "$MANIFEST_DIR/.ostype"
elif [ -n "$OS_FLAVOR" ]
then
echo "Generating .ostype from OS_FLAVOR environment variable."
echo "DEBIAN|$OS_FLAVOR" | tr '[a-z]' '[A-Z]' > "$MANIFEST_DIR/.ostype"
elif [ -f "/opt/oryx/.ostype" ]
then
echo "Copying .ostype from /opt/oryx/.ostype to manifest output directory."
cp "/opt/oryx/.ostype" "$MANIFEST_DIR/.ostype"
else
echo "File $OS_TYPE_SOURCE_DIR does not exist. Cannot copy to manifest directory." 1>&2
echo "No OS flavor environment variable set and /opt/oryx/.ostype does not exist. Cannot generate .ostype." 1>&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion src/BuildScriptGenerator/BuildScriptGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Scriban.Signed" Version="5.5.2" />
<PackageReference Include="Scriban.Signed" Version="7.2.0" />
Comment thread
VindhyaP312 marked this conversation as resolved.
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
<PackageReference Include="System.CodeDom" Version="7.0.0" />
<PackageReference Include="YamlDotNet" Version="12.3.1" />
Expand Down
5 changes: 2 additions & 3 deletions src/BuildScriptGenerator/PlatformInstallerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ protected string GetInstallerScriptSnippet(
snippet
.AppendLine("echo")
.AppendLine("oryxImageDetectorFile=\"/opt/oryx/.imagetype\"")
.AppendLine("oryxOsDetectorFile=\"/opt/oryx/.ostype\"")
.AppendLine($"if [ -f \"$oryxImageDetectorFile\" ] && [ \"$platformName\" = \"dotnet\" ] && grep -q \"jamstack\" \"$oryxImageDetectorFile\"; then")
.AppendLine("echo \"image detector file exists, platform is dotnet..\"")
.AppendLine($"PATH=/opt/dotnet/{version}/dotnet:$PATH")
Expand Down Expand Up @@ -260,9 +259,9 @@ protected string GetInstallerScriptSnippet(
.AppendLine($"mkdir -p /home/codespace/.ruby")
.AppendLine($"ln -sfn /opt/ruby/{version} /home/codespace/.ruby/current")
.AppendLine("fi")
.AppendLine($"if [ -f \"$oryxImageDetectorFile\" ] && [ -f \"$oryxOsDetectorFile\" ] && [ \"$platformName\" = \"python\" ] && grep -q \"githubactions\" \"$oryxImageDetectorFile\" && grep -q \"BULLSEYE\" \"$oryxOsDetectorFile\"; then")
.AppendLine($"if [ -f \"$oryxImageDetectorFile\" ] && [ \"$platformName\" = \"python\" ] && (grep -q \"githubactions\" \"$oryxImageDetectorFile\" || grep -q \"volume-mount\" \"$oryxImageDetectorFile\") && [ \"$DEBIAN_FLAVOR\" = \"bullseye\" ]; then")
.AppendLine($" echo \"image detector file exists, platform is python..\"")
.AppendLine($" echo \"OS detector file exists, OS is bullseye..\"")
.AppendLine($" echo \"OS is bullseye, checking Python version for libffi6 compat..\"")
.AppendLine($" if [ '{version}' == 3.7* ] || [ '{version}' == 3.8* ]; then")
.AppendLine($" curl -LO http://ftp.de.debian.org/debian/pool/main/libf/libffi/libffi6_3.2.1-9_amd64.deb")
.AppendLine($" dpkg -i libffi6_3.2.1-9_amd64.deb")
Expand Down
88 changes: 68 additions & 20 deletions tests/BuildScriptGeneratorCli.Tests/BuildCommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public BuildCommandTest(TestTempDirTestFixture testFixture)
{
_testDir = testFixture;
_testDirPath = testFixture.RootDirPath;

if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DEBIAN_FLAVOR")))
{
Environment.SetEnvironmentVariable("DEBIAN_FLAVOR", "bookworm");
}
}

[Fact]
Expand Down Expand Up @@ -296,31 +301,74 @@ public void OnSuccess_Execute_WritesOnlyBuildOutput_ToStandardOutput()
}

[EnableOnPlatform("LINUX")]
public void BuildScriptFails_WhenOstypeFile_NotPresent()
public void BuildScriptSucceeds_WhenOstypeFile_NotPresent_ButDebianFlavorEnvVarSet()
{
// Arrange
var stringToPrint = "Hello World";
var script = $"#!/bin/bash\necho {stringToPrint}\n";
var serviceProvider = CreateServiceProvider(
new TestProgrammingPlatform(
platformName: "test",
platformVersions: new[] { "1.0.0" },
canGenerateScript: true,
scriptContent: script,
detector: new TestPlatformDetectorUsingPlatformName(
detectedPlatformName: "test",
detectedPlatformVersion: "1.0.0")),
scriptOnly: false,
createOsTypeFile: false);
var buildCommand = new BuildCommand();
var testConsole = new TestConsole(newLineCharacter: string.Empty);

// Act
var exitCode = buildCommand.Execute(serviceProvider, testConsole);
Environment.SetEnvironmentVariable("DEBIAN_FLAVOR", "bookworm");
try
{
var serviceProvider = CreateServiceProvider(
new TestProgrammingPlatform(
platformName: "test",
platformVersions: new[] { "1.0.0" },
canGenerateScript: true,
scriptContent: script,
detector: new TestPlatformDetectorUsingPlatformName(
detectedPlatformName: "test",
detectedPlatformVersion: "1.0.0")),
scriptOnly: false,
createOsTypeFile: false);
var buildCommand = new BuildCommand();
var testConsole = new TestConsole(newLineCharacter: string.Empty);

// Act
var exitCode = buildCommand.Execute(serviceProvider, testConsole);

// Assert
Assert.Equal(0, exitCode);
}
finally
{
Environment.SetEnvironmentVariable("DEBIAN_FLAVOR", null);
}
}

// Assert failed with exit code 1
Assert.Equal(1, exitCode);
Assert.Contains($"File {OS_TYPE_FILE_PATH} does not exist. Cannot copy to manifest directory.", testConsole.StdError);
[EnableOnPlatform("LINUX")]
public void BuildScriptFails_WhenOstypeFile_NotPresent_AndNoEnvVarSet()
{
// Arrange
var stringToPrint = "Hello World";
var script = $"#!/bin/bash\necho {stringToPrint}\n";
var originalDebianFlavor = Environment.GetEnvironmentVariable("DEBIAN_FLAVOR");
Environment.SetEnvironmentVariable("DEBIAN_FLAVOR", null);
try
{
var serviceProvider = CreateServiceProvider(
new TestProgrammingPlatform(
platformName: "test",
platformVersions: new[] { "1.0.0" },
canGenerateScript: true,
scriptContent: script,
detector: new TestPlatformDetectorUsingPlatformName(
detectedPlatformName: "test",
detectedPlatformVersion: "1.0.0")),
scriptOnly: false,
createOsTypeFile: false);
var buildCommand = new BuildCommand();
var testConsole = new TestConsole(newLineCharacter: string.Empty);

// Act
var exitCode = buildCommand.Execute(serviceProvider, testConsole);

// Assert
Assert.Equal(1, exitCode);
}
finally
{
Environment.SetEnvironmentVariable("DEBIAN_FLAVOR", originalDebianFlavor);
}
}

[Fact]
Expand Down
Loading