Skip to content
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

arm64 support #162

Merged
merged 2 commits into from
Dec 30, 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
29 changes: 11 additions & 18 deletions .github/workflows/push-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: authenticate to google cloud
uses: google-github-actions/auth@v2
with:
Expand All @@ -35,30 +39,19 @@ jobs:
gcloud auth configure-docker \
${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev \
--quiet
- name: build container
run: |
docker build \
--tag ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
app/
- name: push container to gar
run: |
docker push \
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
- name: login to ghcr
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login \
ghcr.io \
-u $ \
--password-stdin
- name: tag container for ghcr
run: |
docker tag \
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
ghcr.io/${{ github.repository_owner }}/${{ env.WORKLOAD_NAME }}:latest
- name: push container in ghcr
run: |
docker push \
ghcr.io/${{ github.repository_owner }}/${{ env.WORKLOAD_NAME }}:latest
- name: Build and push
uses: docker/build-push-action@v6
with:
context: app/
platforms: linux/amd64,linux/arm64
push: true
tags: "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},ghcr.io/${{ github.repository_owner }}/${{ env.WORKLOAD_NAME }}:latest"
deploy-humanitec:
needs: build-push
runs-on: ubuntu-24.04
Expand Down
10 changes: 5 additions & 5 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# https://mcr.microsoft.com/v2/dotnet/sdk/tags/list
# https://mcr.microsoft.com/product/dotnet/nightly/sdk
# https://mcr.microsoft.com/v2/dotnet/nightly/sdk/tags/list
FROM mcr.microsoft.com/dotnet/nightly/sdk:9.0.101-noble-aot AS builder
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/nightly/sdk:9.0.101-noble-aot AS builder
ARG TARGETARCH
WORKDIR /app
COPY my-sample-app.csproj .
RUN dotnet restore my-sample-app.csproj \
-r linux-x64
-a $TARGETARCH
COPY . .
RUN dotnet publish my-sample-app.csproj \
-r linux-x64 \
-a $TARGETARCH \
-c release \
-o /my-sample-app \
--no-restore \
--self-contained true \
-p:PublishTrimmed=true \
-p:TrimMode=full
Expand All @@ -27,4 +27,4 @@ COPY --from=builder /my-sample-app .
EXPOSE 8080
ENV ASPNETCORE_HTTP_PORTS=8080
USER 65532
ENTRYPOINT ["/app/my-sample-app"]
ENTRYPOINT ["./my-sample-app"]
8 changes: 6 additions & 2 deletions app/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using System.Runtime.InteropServices;

var builder = WebApplication.CreateSlimBuilder(args);
builder.Configuration.AddJsonFile("appsettings.json", true, true);
Expand All @@ -9,6 +10,9 @@
var message = builder.Configuration["MESSAGE"] ?? "Hello, World! (from code)";
var podName = builder.Configuration["POD_NAME"];
var namespaceName = builder.Configuration["NAMESPACE_NAME"];
message = string.IsNullOrEmpty(podName) || string.IsNullOrEmpty(namespaceName) ? message : $"{message} - from {podName} / {namespaceName}";
var platform = RuntimeInformation.OSArchitecture;
var platformValue = platform == Architecture.Arm64 ? "arm64" : "amd64" ;

app.MapGet("/", () => string.IsNullOrEmpty(podName) || string.IsNullOrEmpty(namespaceName) ? message : $"{message} - from {podName} / {namespaceName}.");
app.Run();
app.MapGet("/", () => $"{message} on {platformValue}.");
app.Run();