-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix: fix an issue causing container deployments to fail when run on an ARM-based system #861
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Projects": [ | ||
{ | ||
"Name": "AWS.Deploy.CLI", | ||
"Type": "Minor", | ||
"ChangelogMessages": [ | ||
"Fix an issue causing container deployments to fail when run on an ARM-based system" | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM {docker-base-image} AS base{non-root-user} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fix to container deployments only applies to .NET 7 and newer, so this dockerfile template is the version we currently use and will continue to be used for .NET6 and older targets. |
||
WORKDIR /app | ||
{exposed-ports} | ||
|
||
FROM {docker-build-image} AS build | ||
WORKDIR /src | ||
{project-path-list} | ||
RUN dotnet restore "{project-path}" | ||
COPY . . | ||
WORKDIR "/src/{project-folder}" | ||
RUN dotnet build "{project-name}" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN apt-get update -yq \ | ||
&& apt-get install -yq ca-certificates curl gnupg \ | ||
&& mkdir -p /etc/apt/keyrings \ | ||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ | ||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ | ||
&& apt-get update -yq \ | ||
&& apt-get install nodejs -yq | ||
RUN dotnet publish "{project-name}" -c Release -o /app/publish | ||
|
||
FROM base AS final{http-port-env-variable} | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "{assembly-name}.dll"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,6 @@ | |
<RootNamespace>AWS.Deploy.Orchestration</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a project reference to |
||
<Compile Include="..\AWS.Deploy.Recipes.CDK.Common\RecipeProps.cs" Link="RecipeProps.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AWSSDK.CloudControlApi" Version="3.7.300.77" /> | ||
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.302.18" /> | ||
|
@@ -31,14 +27,15 @@ | |
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.TemplateEngine.IDE" Version="5.0.1" /> | ||
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="5.0.1" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageReference Include="System.Linq.Async" Version="6.0.1" /> | ||
<PackageReference Include="YamlDotNet" Version="13.4.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AWS.Deploy.Recipes\AWS.Deploy.Recipes.csproj" /> | ||
<ProjectReference Include="..\AWS.Deploy.DockerEngine\AWS.Deploy.DockerEngine.csproj" /> | ||
<ProjectReference Include="..\AWS.Deploy.Recipes.CDK.Common\AWS.Deploy.Recipes.CDK.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,11 @@ | |
DockerUtilities.TryGetAbsoluteDockerfile(recommendation, _fileManager, _directoryManager, out var dockerFile); | ||
|
||
var dockerBuildCommand = $"docker build -t {imageTag} -f \"{dockerFile}\"{buildArgs} ."; | ||
if (RuntimeInformation.OSArchitecture != Architecture.X64) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't currently support running tests on non X64 architectures, so this code path will not be tested in our CI. However, this code path is covered using existing tests when run on ARM. |
||
{ | ||
dockerBuildCommand = $"docker buildx build --platform linux/amd64 -t {imageTag} -f \"{dockerFile}\"{buildArgs} ."; | ||
} | ||
|
||
_interactiveService.LogInfoMessage($"Docker Execution Directory: {Path.GetFullPath(dockerExecutionDirectory)}"); | ||
_interactiveService.LogInfoMessage($"Docker Build Command: {dockerBuildCommand}"); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ public void GenerateCDKProjectFromTemplate(Recommendation recommendation, Orches | |
{ | ||
throw new InvalidOperationException($"{nameof(recommendation.Recipe.CdkProjectTemplateId)} cannot be null or an empty string"); | ||
} | ||
|
||
//The location of the base template that will be installed into the templating engine | ||
var cdkProjectTemplateDirectory = Path.Combine( | ||
Path.GetDirectoryName(recommendation.Recipe.RecipePath) ?? | ||
|
@@ -67,7 +67,7 @@ public void GenerateCDKProjectFromTemplate(Recommendation recommendation, Orches | |
var templateParameters = new Dictionary<string, string> { | ||
// CDK Template projects can parameterize the version number of the AWS.Deploy.Recipes.CDK.Common package. This avoid | ||
// projects having to be modified every time the package version is bumped. | ||
{ "AWSDeployRecipesCDKCommonVersion", FileVersionInfo.GetVersionInfo(typeof(Constants.CloudFormationIdentifier).Assembly.Location).ProductVersion | ||
{ "AWSDeployRecipesCDKCommonVersion", FileVersionInfo.GetVersionInfo(typeof(AWS.Deploy.Recipes.CDK.Common.CDKRecipeSetup).Assembly.Location).ProductVersion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we dropped Nerdbank.GitVersioning, this code was bugged as it always returned 1.0.0. This is because |
||
?? throw new InvalidAWSDeployRecipesCDKCommonVersionException(DeployToolErrorCode.InvalidAWSDeployRecipesCDKCommonVersion, "The version number of the AWS.Deploy.Recipes.CDK.Common package is invalid.") } | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am specifically checking the following target framework to maintain consistency with other parts of the codebase that also have the same check for different purposes.