From ed03be3822e43ef4b7752ca62ef1dbeb8054e47e Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 18:35:55 +0400 Subject: [PATCH 01/37] Add Docker support --- .dockerignore | 25 +++++++++++++++++++++++++ src/Argon.Api/Argon.Api.csproj | 7 +++++++ src/Argon.Api/Dockerfile | 24 ++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .dockerignore create mode 100644 src/Argon.Api/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cd967fc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/.idea +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/src/Argon.Api/Argon.Api.csproj b/src/Argon.Api/Argon.Api.csproj index ede983a..ecf2e7e 100644 --- a/src/Argon.Api/Argon.Api.csproj +++ b/src/Argon.Api/Argon.Api.csproj @@ -4,6 +4,7 @@ net8.0 enable enable + Linux @@ -23,4 +24,10 @@ + + + .dockerignore + + + diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile new file mode 100644 index 0000000..058d01f --- /dev/null +++ b/src/Argon.Api/Dockerfile @@ -0,0 +1,24 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] +COPY ["src/ServiceDefaults/ServiceDefaults.csproj", "src/ServiceDefaults/"] +RUN dotnet restore "src/Argon.Api/Argon.Api.csproj" +COPY . . +WORKDIR "/src/src/Argon.Api" +RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Argon.Api.dll"] From 6cf5dbece88796e9c2f24fdd9a436e7c6dbc5b67 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 18:48:01 +0400 Subject: [PATCH 02/37] Update GitHub Actions workflows for .NET project. --- .github/workflows/api.yml | 35 +++++++++++++++++++++++++++++++++++ .github/workflows/dotnet.yml | 28 ---------------------------- 2 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/api.yml delete mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml new file mode 100644 index 0000000..b15b0c4 --- /dev/null +++ b/.github/workflows/api.yml @@ -0,0 +1,35 @@ +name: .NET + +on: + push: + branches: [ "master" ] + paths: + - 'src/Argon.Api/**' + pull_request: + branches: [ "master" ] + paths: + - 'src/Argon.Api/**' + +jobs: + build: + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + env: + IMAGE_TAG: $(date +%s) + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v1 + with: + registry: ${{ secrets.REGISTRY }} + username: ${{ secrets.CR_USER }} + password: ${{ secrets.CR_PWD }} + - name: Build and push images + run: | + docker build -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG . -f src/Argon.Api/Dockerfile --push + docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest + docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml deleted file mode 100644 index 6b96b57..0000000 --- a/.github/workflows/dotnet.yml +++ /dev/null @@ -1,28 +0,0 @@ -# This workflow will build a .NET project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net - -name: .NET - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - # - name: Restore dependencies - # run: dotnet restore - # - name: Build - # run: dotnet build --no-restore - # - name: Test - # run: dotnet test --no-build --verbosity normal From eb8616c6fe7a093c878777eade2774385c84bcc5 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 18:49:12 +0400 Subject: [PATCH 03/37] Disable conditional run for the build job in CI. --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index b15b0c4..c3139da 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -12,7 +12,7 @@ on: jobs: build: - if: github.ref == 'refs/heads/master' +# if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest env: IMAGE_TAG: $(date +%s) From a87c315e515343ffb00da4405f79c8ddb2469c38 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 18:49:34 +0400 Subject: [PATCH 04/37] [skip ci] Enable conditional job execution for the build workflow --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index c3139da..b15b0c4 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -12,7 +12,7 @@ on: jobs: build: -# if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest env: IMAGE_TAG: $(date +%s) From 4771273c4caac272f56c25f74834988318696a38 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 18:50:54 +0400 Subject: [PATCH 05/37] Comment out build condition and adjust Dockerfile path --- .github/workflows/api.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index b15b0c4..605f328 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -12,7 +12,7 @@ on: jobs: build: - if: github.ref == 'refs/heads/master' +# if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest env: IMAGE_TAG: $(date +%s) @@ -28,8 +28,10 @@ jobs: registry: ${{ secrets.REGISTRY }} username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PWD }} + - name: Print tag + run: echo $IMAGE_TAG - name: Build and push images run: | - docker build -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG . -f src/Argon.Api/Dockerfile --push + docker build . -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile --push docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From a9dd1c7974b7c6a5fcb87ede66d99e682315b8f7 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 18:52:22 +0400 Subject: [PATCH 06/37] Refactor IMAGE_TAG environment variable setup --- .github/workflows/api.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 605f328..0fdeb42 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -14,8 +14,6 @@ jobs: build: # if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest - env: - IMAGE_TAG: $(date +%s) steps: - uses: actions/checkout@v4 - name: Setup .NET @@ -32,6 +30,8 @@ jobs: run: echo $IMAGE_TAG - name: Build and push images run: | + export IMAGE_TAG=$(date +%s) + echo $IMAGE_TAG docker build . -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile --push docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From 4cee91fae5d8e936a00be1bf6344e0d062dd5f27 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:29:33 +0400 Subject: [PATCH 07/37] Add ARM64 platform support to Docker build --- .github/workflows/api.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 0fdeb42..eb85805 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -26,12 +26,10 @@ jobs: registry: ${{ secrets.REGISTRY }} username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PWD }} - - name: Print tag - run: echo $IMAGE_TAG - name: Build and push images run: | export IMAGE_TAG=$(date +%s) echo $IMAGE_TAG - docker build . -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile --push + docker build --platform linux/arm64 . -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile --push docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From 76626729e201b723e5bd432039fce8d4b98ee02f Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:32:47 +0400 Subject: [PATCH 08/37] Update Dockerfile to use alpine3.18-arm64v8 images --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 058d01f..fb7f7ce 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18-arm64v8 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine3.18-arm64v8 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From 4dcd11921999671c5b090ffcbe2a0c96de380247 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:35:50 +0400 Subject: [PATCH 09/37] Fix Docker build platform in GitHub Action --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index eb85805..568f04a 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -30,6 +30,6 @@ jobs: run: | export IMAGE_TAG=$(date +%s) echo $IMAGE_TAG - docker build --platform linux/arm64 . -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile --push + docker build --platform=linux/aarch64 -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From 78cd5876c384a835107be82db1a0c8fff4908ba7 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:37:38 +0400 Subject: [PATCH 10/37] Switch to bullseye-slim base images in Dockerfile --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index fb7f7ce..8e14d2b 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18-arm64v8 AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0-bullseye-slim-arm64v8 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine3.18-arm64v8 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-bullseye-slim-arm64v8 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From dc762c8369ea2f701ac11df894bf641de4db239b Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:39:44 +0400 Subject: [PATCH 11/37] Update Dockerfile to use alpine-based .NET images --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 8e14d2b..17cbafa 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0-bullseye-slim-arm64v8 AS base +FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18-arm64v8 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM mcr.microsoft.com/dotnet/sdk:8.0-bullseye-slim-arm64v8 AS build +FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/sdk:8.0-alpine3.18-arm64v8 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From f9097930f0694b835286bb2735e157f955ab6188 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:40:41 +0400 Subject: [PATCH 12/37] Update Dockerfile to use non-Alpine .NET images --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 17cbafa..569b88b 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18-arm64v8 AS base +FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/sdk:8.0-alpine3.18-arm64v8 AS build +FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From 4eadf695b5ea6b9f6c189cf47180419bf8f8da38 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:44:43 +0400 Subject: [PATCH 13/37] Use build platform variable in Dockerfile --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 569b88b..1518159 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM --platform=linux/aarch64 mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From 9b0711f233b400a8338dbce6c2fb14cc7fc2d189 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:47:03 +0400 Subject: [PATCH 14/37] Switch to Alpine base images in Dockerfile --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 1518159..40a6c1e 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From 86be8bc067cd908d87b3cc7df80a54e53b4c1266 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:51:40 +0400 Subject: [PATCH 15/37] Disable tagging and pushing as latest in Docker workflow --- .github/workflows/api.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 568f04a..6072bcf 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -31,5 +31,5 @@ jobs: export IMAGE_TAG=$(date +%s) echo $IMAGE_TAG docker build --platform=linux/aarch64 -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push - docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest - docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file +# docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest +# docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From 403798c95752dbe6e703f50318ef4a7689fd80b7 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:54:48 +0400 Subject: [PATCH 16/37] Update Docker image tag in GitHub Actions workflow --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 6072bcf..32442d0 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -30,6 +30,6 @@ jobs: run: | export IMAGE_TAG=$(date +%s) echo $IMAGE_TAG - docker build --platform=linux/aarch64 -t ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push + docker build --platform=linux/aarch64 -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push # docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest # docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From ec5335e7450449604923a264067f8dd0b78cacb1 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 19:58:39 +0400 Subject: [PATCH 17/37] Update Docker build command to use buildx --- .github/workflows/api.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 32442d0..313bd03 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -29,7 +29,8 @@ jobs: - name: Build and push images run: | export IMAGE_TAG=$(date +%s) - echo $IMAGE_TAG - docker build --platform=linux/aarch64 -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push + docker buildx ls + docker buildx inspect + docker buildx build --platform=linux/aarch64 -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push # docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest # docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From e516a0811d7507818ce754d6adc952e6720bc3cf Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:02:36 +0400 Subject: [PATCH 18/37] Set Docker default platform to linux/arm64 --- .github/workflows/api.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 313bd03..d357b17 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -28,6 +28,7 @@ jobs: password: ${{ secrets.CR_PWD }} - name: Build and push images run: | + export DOCKER_DEFAULT_PLATFORM=linux/arm64 export IMAGE_TAG=$(date +%s) docker buildx ls docker buildx inspect From 6e600c639733b421ee78daf8da899675d40affcb Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:05:13 +0400 Subject: [PATCH 19/37] Add architecture support to Dockerfile --- src/Argon.Api/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 40a6c1e..cc342f9 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,4 +1,5 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base +ARG TARGETARCH USER $APP_UID WORKDIR /app EXPOSE 8080 @@ -9,10 +10,10 @@ ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] COPY ["src/ServiceDefaults/ServiceDefaults.csproj", "src/ServiceDefaults/"] -RUN dotnet restore "src/Argon.Api/Argon.Api.csproj" +RUN dotnet restore "src/Argon.Api/Argon.Api.csproj" -a $TARGETARCH COPY . . WORKDIR "/src/src/Argon.Api" -RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build +RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -a $TARGETARCH -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release From efb561124b49d5a59bb3b709d016f04a1bfe4f49 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:09:48 +0400 Subject: [PATCH 20/37] Switch to linux-arm64 runtime in Dockerfile --- src/Argon.Api/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index cc342f9..e804830 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,5 +1,4 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base -ARG TARGETARCH USER $APP_UID WORKDIR /app EXPOSE 8080 @@ -10,14 +9,14 @@ ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] COPY ["src/ServiceDefaults/ServiceDefaults.csproj", "src/ServiceDefaults/"] -RUN dotnet restore "src/Argon.Api/Argon.Api.csproj" -a $TARGETARCH +RUN dotnet restore "src/Argon.Api/Argon.Api.csproj" -r linux-arm64 COPY . . WORKDIR "/src/src/Argon.Api" -RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -a $TARGETARCH -o /app/build +RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -r linux-arm64 -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "Argon.Api.csproj" -c $BUILD_CONFIGURATION -r linux-arm64 -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app From 28a9e03a1b36e6602b6fb36ff9cf1dd594fa7a13 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:13:46 +0400 Subject: [PATCH 21/37] Integrate QEMU and Buildx for multi-arch Docker builds --- .github/workflows/api.yml | 4 ++++ src/Argon.Api/Dockerfile | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index d357b17..a23f3b3 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -20,6 +20,10 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - name: Log in to GitHub Docker Registry uses: docker/login-action@v1 with: diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index e804830..40a6c1e 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -9,14 +9,14 @@ ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] COPY ["src/ServiceDefaults/ServiceDefaults.csproj", "src/ServiceDefaults/"] -RUN dotnet restore "src/Argon.Api/Argon.Api.csproj" -r linux-arm64 +RUN dotnet restore "src/Argon.Api/Argon.Api.csproj" COPY . . WORKDIR "/src/src/Argon.Api" -RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -r linux-arm64 -o /app/build +RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "Argon.Api.csproj" -c $BUILD_CONFIGURATION -r linux-arm64 -o /app/publish /p:UseAppHost=false +RUN dotnet publish "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app From e03462386ed75aa910a8b32f213d5a9e89c966e3 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:14:22 +0400 Subject: [PATCH 22/37] Add Docker layer caching to CI workflow --- .github/workflows/api.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index a23f3b3..cadad82 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -24,6 +24,13 @@ jobs: uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: Log in to GitHub Docker Registry uses: docker/login-action@v1 with: From ee06fecdee1847d31b9cf55f25a78f5ad04f7ff4 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:16:25 +0400 Subject: [PATCH 23/37] Change build platform to arm64 and remove redundant platform specifiers --- .github/workflows/api.yml | 2 +- src/Argon.Api/Dockerfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index cadad82..f21867c 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -43,6 +43,6 @@ jobs: export IMAGE_TAG=$(date +%s) docker buildx ls docker buildx inspect - docker buildx build --platform=linux/aarch64 -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push + docker buildx build --platform=linux/arm64 -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push # docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest # docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 40a6c1e..058d01f 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From b8d5325dfd619906a39b9f4288ebb006f33bbb30 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:17:39 +0400 Subject: [PATCH 24/37] Simplify Docker build command --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index f21867c..6ed9941 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -43,6 +43,6 @@ jobs: export IMAGE_TAG=$(date +%s) docker buildx ls docker buildx inspect - docker buildx build --platform=linux/arm64 -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push + docker build -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push # docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest # docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file From 6a4a384208169b6e9136cb3ea193fcbb5f266686 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:21:32 +0400 Subject: [PATCH 25/37] Update Docker image build and push process --- .github/workflows/api.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 6ed9941..728265e 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -37,12 +37,13 @@ jobs: registry: ${{ secrets.REGISTRY }} username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PWD }} - - name: Build and push images - run: | - export DOCKER_DEFAULT_PLATFORM=linux/arm64 - export IMAGE_TAG=$(date +%s) - docker buildx ls - docker buildx inspect - docker build -t ${{ secrets.REGISTRY }}/argongg/api-orleans:$IMAGE_TAG -f ./src/Argon.Api/Dockerfile . --push -# docker tag ${{ secrets.REGISTRY }}/argongg/api:$IMAGE_TAG ${{ secrets.REGISTRY }}/argongg/api:latest -# docker push ${{ secrets.REGISTRY }}/argongg/api:latest \ No newline at end of file + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./src/Argon.Api/Dockerfile + push: true + tags: ${{ secrets.REGISTRY }}/argongg/api-orleans:$(date +%s) + platforms: linux/arm64/v8 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file From ef3eca03a4b2e315f219d3e2c1dd42e6c6f25f2f Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:23:12 +0400 Subject: [PATCH 26/37] Update Docker image tags --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 728265e..aa5f9e7 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -43,7 +43,7 @@ jobs: context: . file: ./src/Argon.Api/Dockerfile push: true - tags: ${{ secrets.REGISTRY }}/argongg/api-orleans:$(date +%s) + tags: argongg/api-orleans:$(date +%s) platforms: linux/arm64/v8 cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file From 38d11faba2a196365e5583ab864c43bc59209b03 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:24:41 +0400 Subject: [PATCH 27/37] Update Docker image tag to use GitHub run number --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index aa5f9e7..545b2f6 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -43,7 +43,7 @@ jobs: context: . file: ./src/Argon.Api/Dockerfile push: true - tags: argongg/api-orleans:$(date +%s) + tags: argon/api-orleans:${{ github.run_number }} platforms: linux/arm64/v8 cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file From 8c53d4a698c2187957dd83e93d74674d46eed6d6 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:30:40 +0400 Subject: [PATCH 28/37] Switch from Alpine to non-Alpine .NET images --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 058d01f..3059e76 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From 8687e24976b46f17e7e9423b1cdf63960a1cfcd8 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:32:44 +0400 Subject: [PATCH 29/37] Enable multi-platform builds in Dockerfile --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 3059e76..1518159 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From db35f2f8a8ff37a713589f1464a9dc97bbcb4a01 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:35:06 +0400 Subject: [PATCH 30/37] Update Docker tag to staging registry --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 545b2f6..6f50569 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -43,7 +43,7 @@ jobs: context: . file: ./src/Argon.Api/Dockerfile push: true - tags: argon/api-orleans:${{ github.run_number }} + tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }} platforms: linux/arm64/v8 cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file From a834393dc213db01801c37a04534bdd6ecde50a1 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:41:15 +0400 Subject: [PATCH 31/37] Switch to Alpine-based images for ARM64 support --- src/Argon.Api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 1518159..c762dfd 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18-arm64v8 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine3.18-arm64v8 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From 4c3c3270a1a8ab2d494201aab28dfdd6683990cf Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:44:21 +0400 Subject: [PATCH 32/37] Rename job to 'qa' and update Dockerfile base images --- .github/workflows/api.yml | 63 +++++++++++++++++++++------------------ src/Argon.Api/Dockerfile | 4 +-- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 6f50569..fad1b17 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -11,8 +11,7 @@ on: - 'src/Argon.Api/**' jobs: - build: -# if: github.ref == 'refs/heads/master' + qa: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -20,30 +19,36 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Log in to GitHub Docker Registry - uses: docker/login-action@v1 - with: - registry: ${{ secrets.REGISTRY }} - username: ${{ secrets.CR_USER }} - password: ${{ secrets.CR_PWD }} - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./src/Argon.Api/Dockerfile - push: true - tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }} - platforms: linux/arm64/v8 - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file + build: + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + needs: qa + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v1 + with: + registry: ${{ secrets.REGISTRY }} + username: ${{ secrets.CR_USER }} + password: ${{ secrets.CR_PWD }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./src/Argon.Api/Dockerfile + push: true + tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }} + platforms: linux/arm64/v8 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + \ No newline at end of file diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index c762dfd..9e43afa 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18-arm64v8 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-arm64v8 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine3.18-arm64v8 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine-arm64v8 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] From 7f657959a8fc4d3ea1dd5c5863c2d4b5f341efca Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:44:45 +0400 Subject: [PATCH 33/37] Add checkout step to API workflow --- .github/workflows/api.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index fad1b17..0c3fdf3 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -24,6 +24,7 @@ jobs: runs-on: ubuntu-latest needs: qa steps: + - uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx From c39fef1057d9a32af7d2a262f3278ae8f69d5394 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 14 Oct 2024 20:45:37 +0400 Subject: [PATCH 34/37] Disable build step conditional in GitHub Actions workflow --- .github/workflows/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 0c3fdf3..bde17bb 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -20,7 +20,7 @@ jobs: with: dotnet-version: 8.0.x build: - if: github.ref == 'refs/heads/master' +# if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest needs: qa steps: From d15adf6fb43669963d9cc6d7f279ae8c68ef1f0a Mon Sep 17 00:00:00 2001 From: Aram Date: Tue, 15 Oct 2024 03:17:17 +0400 Subject: [PATCH 35/37] Update configurations and add build time endpoint --- .github/workflows/api.yml | 6 +++--- src/Argon.Api/Dockerfile | 4 ++-- src/Argon.Api/Program.cs | 7 ++++--- src/Argon.Api/appsettings.json | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index bde17bb..cd70edc 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -12,7 +12,7 @@ on: jobs: qa: - runs-on: ubuntu-latest + runs-on: ARM64 steps: - uses: actions/checkout@v4 - name: Setup .NET @@ -21,7 +21,7 @@ jobs: dotnet-version: 8.0.x build: # if: github.ref == 'refs/heads/master' - runs-on: ubuntu-latest + runs-on: ARM64 needs: qa steps: - uses: actions/checkout@v4 @@ -49,7 +49,7 @@ jobs: file: ./src/Argon.Api/Dockerfile push: true tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }} - platforms: linux/arm64/v8 +# platforms: linux/arm64/v8 cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file diff --git a/src/Argon.Api/Dockerfile b/src/Argon.Api/Dockerfile index 9e43afa..84630df 100644 --- a/src/Argon.Api/Dockerfile +++ b/src/Argon.Api/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-arm64v8 AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-arm64v8 AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine-arm64v8 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-arm64v8 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"] diff --git a/src/Argon.Api/Program.cs b/src/Argon.Api/Program.cs index 6502a28..b3d3cd1 100644 --- a/src/Argon.Api/Program.cs +++ b/src/Argon.Api/Program.cs @@ -21,20 +21,21 @@ public static async Task Main(string[] args) siloBuilder.AddMemoryGrainStorage("replaceme"); // TODO: replace me pls }); var app = builder.Build(); + app.UseSwagger(); + app.UseSwaggerUI(); if (app.Environment.IsDevelopment()) { - app.UseSwagger(); - app.UseSwaggerUI(); using var scope = app.Services.CreateScope(); var db = scope.ServiceProvider.GetRequiredService(); Thread.Sleep(5000); await db.Database.MigrateAsync(); } - app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.MapDefaultEndpoints(); + var buildTime = File.GetLastWriteTimeUtc(typeof(Program).Assembly.Location); + app.MapGet("/", () => buildTime); await app.RunAsync(); } } \ No newline at end of file diff --git a/src/Argon.Api/appsettings.json b/src/Argon.Api/appsettings.json index f943254..a41c41d 100644 --- a/src/Argon.Api/appsettings.json +++ b/src/Argon.Api/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Host=database;Port=5432;Username=svck;Password=Password123;Database=apiDb", + "DefaultConnection": "Host=localhost;Port=5432;Username=svck;Password=1ed1f86a265ecffa4c0de1a1;Database=argon_api", "cache": "localhost:1500", "rmq": "amqp://svck:Password123@localhost:5672" }, From 7e4596cd40b38544d41f5d26f78ec85b2d58f2db Mon Sep 17 00:00:00 2001 From: Aram Date: Tue, 15 Oct 2024 03:21:33 +0400 Subject: [PATCH 36/37] Remove QEMU and Docker caching setup steps --- .github/workflows/api.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index cd70edc..2ace157 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -24,18 +24,6 @@ jobs: runs-on: ARM64 needs: qa steps: - - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - name: Log in to GitHub Docker Registry uses: docker/login-action@v1 with: @@ -50,6 +38,4 @@ jobs: push: true tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }} # platforms: linux/arm64/v8 - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file From 7886ca6b609518baea36e1aa960021c281fcf94e Mon Sep 17 00:00:00 2001 From: Aram Date: Tue, 15 Oct 2024 03:32:32 +0400 Subject: [PATCH 37/37] Refactor root endpoint to return an anonymous object. --- src/Argon.Api/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Argon.Api/Program.cs b/src/Argon.Api/Program.cs index b3d3cd1..1a1cb98 100644 --- a/src/Argon.Api/Program.cs +++ b/src/Argon.Api/Program.cs @@ -35,7 +35,7 @@ public static async Task Main(string[] args) app.MapControllers(); app.MapDefaultEndpoints(); var buildTime = File.GetLastWriteTimeUtc(typeof(Program).Assembly.Location); - app.MapGet("/", () => buildTime); + app.MapGet("/", () => new { buildTime = buildTime }); await app.RunAsync(); } } \ No newline at end of file