Repository: featbit/featbit (language: python)

Issue:
🏗 fix: multi platform dotnet project docker build hangs
Reference

- https://github.com/dotnet/runtime/issues/97828
- https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/api-server-validations.yml b/.github/workflows/api-server-validations.yml
deleted file mode 100644
index 08837f533..000000000
--- a/.github/workflows/api-server-validations.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-# Validate the api-server and evaluation-server when code changes
-
-name: API-Server change validations
-on:
-  workflow_dispatch:
-  push:
-    branches:
-      - main
-    paths:
-      - 'modules/back-end/**'
-      - '.github/api-server-validations.yml'
-  pull_request:
-    branches:
-      - main
-    paths:
-      - 'modules/back-end/**'
-      - '.github/api-server-validations.yml'
-
-jobs:
-  validate:
-    name: Validate API-Server
-    runs-on: ubuntu-latest
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v3
-
-      - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v2
-
-      - name: Build - API-Server
-        uses: docker/build-push-action@v4
-        with:
-          context: "{{defaultContext}}:modules/back-end"
-          file: ./deploy/Dockerfile
-          platforms: linux/amd64
-          push: false
diff --git a/.github/workflows/evaluation-server-validations.yml b/.github/workflows/evaluation-server-validations.yml
deleted file mode 100644
index e060ed4f1..000000000
--- a/.github/workflows/evaluation-server-validations.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-# Validate the evaluation-server when code changes
-
-name: Evaluation-Server change validations
-on:
-  workflow_dispatch:
-  push:
-    branches:
-      - main
-    paths:
-      - 'modules/evaluation-server/**'
-      - '.github/evaluation-server-validations.yml'
-  pull_request:
-    branches:
-      - main
-    paths:
-      - 'modules/evaluation-server/**'
-      - '.github/evaluation-server-validations.yml'
-
-jobs:
-
-  validate:
-    name: Validate Evaluation-Server
-    runs-on: ubuntu-latest
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v3
-
-      - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v2
-
-      - name: Build - Evaluation-Server
-        uses: docker/build-push-action@v4
-        with:
-          context: "{{defaultContext}}:modules/evaluation-server"
-          file: ./deploy/Dockerfile
-          platforms: linux/amd64
-          push: false
diff --git a/modules/back-end/deploy/Dockerfile b/modules/back-end/deploy/Dockerfile
index cd88273fa..c7ee4a7d9 100644
--- a/modules/back-end/deploy/Dockerfile
+++ b/modules/back-end/deploy/Dockerfile
@@ -19,15 +19,14 @@ RUN for file in $(ls *.csproj); do mkdir -p tests/${file%.*}/ && mv $file tests/
 
 RUN dotnet restore -a $TARGETARCH
 
-# copy all source, build and test
+# copy everything else
 COPY . .
-RUN dotnet build -p:TargetArch=$TARGETARCH -c Release --no-restore && dotnet test
 
 # publish stage
 FROM build AS publish
 ARG INSTALL_DIR
 WORKDIR /source/src/Api
-RUN dotnet publish -a $TARGETARCH --no-build -o $INSTALL_DIR
+RUN dotnet publish -a $TARGETARCH --no-restore -o $INSTALL_DIR
 
 # final stage/image
 FROM mcr.microsoft.com/dotnet/aspnet:8.0
diff --git a/modules/evaluation-server/deploy/Dockerfile b/modules/evaluation-server/deploy/Dockerfile
index 35aefefaa..55f993276 100644
--- a/modules/evaluation-server/deploy/Dockerfile
+++ b/modules/evaluation-server/deploy/Dockerfile
@@ -19,15 +19,14 @@ RUN for file in $(ls *.csproj); do mkdir -p tests/${file%.*}/ && mv $file tests/
 
 RUN dotnet restore -a $TARGETARCH
 
-# copy all source, build and test
+# copy everything else
 COPY . .
-RUN dotnet build -p:TargetArch=$TARGETARCH -c Release --no-restore && dotnet test
 
 # publish stage
 FROM build AS publish
 ARG INSTALL_DIR
 WORKDIR /source/src/Api
-RUN dotnet publish -a $TARGETARCH --no-build -o $INSTALL_DIR
+RUN dotnet publish -a $TARGETARCH --no-restore -o $INSTALL_DIR
 
 # final stage/image
 FROM mcr.microsoft.com/dotnet/aspnet:8.0


Test patch:
diff --git a/.github/workflows/build-and-test-api.yml b/.github/workflows/build-and-test-api.yml
new file mode 100644
index 000000000..622d5a06f
--- /dev/null
+++ b/.github/workflows/build-and-test-api.yml
@@ -0,0 +1,40 @@
+name: Build and Test API-Server
+on:
+  workflow_dispatch:
+  push:
+    branches:
+      - main
+    paths:
+      - 'modules/back-end/**'
+      - '.github/build-and-test-api.yml'
+  pull_request:
+    branches:
+      - main
+    paths:
+      - 'modules/back-end/**'
+      - '.github/build-and-test-api.yml'
+
+jobs:
+  validate:
+    name: build-and-test-els
+    runs-on: ubuntu-latest
+    defaults:
+      run:
+        working-directory: modules/back-end
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Setup .NET
+        uses: actions/setup-dotnet@v4
+        with:
+          dotnet-version: '8.0.x'
+
+      - name: Restore Packages
+        run: dotnet restore
+
+      - name: Build Solution
+        run: dotnet build -c Release --no-restore
+
+      - name: Run Tests
+        run: dotnet test -c Release --no-build --verbosity normal
diff --git a/.github/workflows/build-and-test-els.yml b/.github/workflows/build-and-test-els.yml
new file mode 100644
index 000000000..a93cbadc4
--- /dev/null
+++ b/.github/workflows/build-and-test-els.yml
@@ -0,0 +1,40 @@
+name: Build and Test Evaluation-Server
+on:
+  workflow_dispatch:
+  push:
+    branches:
+      - main
+    paths:
+      - 'modules/evaluation-server/**'
+      - '.github/build-and-test-els.yml'
+  pull_request:
+    branches:
+      - main
+    paths:
+      - 'modules/evaluation-server/**'
+      - '.github/build-and-test-els.yml'
+
+jobs:
+  validate:
+    name: build-and-test-els
+    runs-on: ubuntu-latest
+    defaults:
+      run:
+        working-directory: modules/evaluation-server
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Setup .NET
+        uses: actions/setup-dotnet@v4
+        with:
+          dotnet-version: '8.0.x'
+
+      - name: Restore Packages
+        run: dotnet restore
+
+      - name: Build Solution
+        run: dotnet build -c Release --no-restore
+
+      - name: Run Tests
+        run: dotnet test -c Release --no-build --verbosity normal