diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..cb71a42f6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,26 @@ +**/.DS_Store +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/artifacts +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!.git/HEAD +!.git/config +!.git/refs/heads/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac77ee62e..2cc6104fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,6 +68,11 @@ jobs: file: ./artifacts/coverage/coverage.cobertura.xml flags: ${{ matrix.os_name }} + - name: Build for arm64 with Docker + if: runner.os == 'Linux' + run: | + docker build --platform linux/arm64 --output . . + - name: Publish artifacts uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 with: @@ -77,7 +82,7 @@ jobs: - name: Create Lambda ZIP file if: runner.os == 'Linux' run: | - cd "./artifacts/publish/LondonTravel.Skill/release_linux-x64" || exit + cd "./artifacts/publish/LondonTravel.Skill/release_linux-arm64" || exit if [ -f "./bootstrap" ] then chmod +x ./bootstrap diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..f82863e39 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0@sha256:bb65e39b662be0265f780afae9cdbfcaa315ef63edb245ad9fb2aa1aabca0b6b AS build +ARG TARGETARCH + +RUN dpkg --add-architecture arm64 +RUN apt update && apt install --yes clang gcc-aarch64-linux-gnu llvm zlib1g-dev zlib1g-dev:arm64 + +WORKDIR /source + +COPY . . +RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ + dotnet publish ./src/LondonTravel.Skill --runtime linux-arm64 --self-contained true /p:AssemblyName=bootstrap /p:PublishAot=true /p:PublishReadyToRun=true + +FROM scratch AS export +ARG TARGETARCH +COPY --from=build /source/artifacts/publish/LondonTravel.Skill/release_*/ ./artifacts/publish/LondonTravel.Skill/release_arm64 diff --git a/src/LondonTravel.Skill/aws-lambda-tools-defaults.json b/src/LondonTravel.Skill/aws-lambda-tools-defaults.json index 591770fad..1dfbe0a8e 100644 --- a/src/LondonTravel.Skill/aws-lambda-tools-defaults.json +++ b/src/LondonTravel.Skill/aws-lambda-tools-defaults.json @@ -3,7 +3,7 @@ "region": "eu-west-1", "configuration": "Release", "framework": "net8.0", - "function-architecture": "x86_64", + "function-architecture": "arm64", "function-handler": "LondonTravel.Skill", "function-memory-size": 192, "function-runtime": "provided.al2023",