diff --git a/.github/workflows/buid-api-messagebus.yaml b/.github/workflows/buid-api-messagebus.yaml new file mode 100644 index 0000000..5d49f85 --- /dev/null +++ b/.github/workflows/buid-api-messagebus.yaml @@ -0,0 +1,48 @@ +name: Create and publish an api messagebus Docker image + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}-api-messagebus + PLATFORM_BUILDS: linux/amd64,linux/arm64 + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./src/Server.Controllers.Api.MessageBus/Dockerfile + push: true + platforms: ${{ env.PLATFORM_BUILDS }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/buid-api-web.yaml b/.github/workflows/buid-api-web.yaml new file mode 100644 index 0000000..0b6794a --- /dev/null +++ b/.github/workflows/buid-api-web.yaml @@ -0,0 +1,48 @@ +name: Create and publish an api web Docker image + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}-api-web + PLATFORM_BUILDS: linux/amd64,linux/arm64 + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./src/Server.Controllers.Api.Web/Dockerfile + push: true + platforms: ${{ env.PLATFORM_BUILDS }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/MadWorldNL.CloudPlayground.sln b/MadWorldNL.CloudPlayground.sln index 4e65762..472bc50 100644 --- a/MadWorldNL.CloudPlayground.sln +++ b/MadWorldNL.CloudPlayground.sln @@ -43,6 +43,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.MessageBus", "src\Serve EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessageBus.Contracts", "src\Server.Logical.MessageBus.Contracts\MessageBus.Contracts.csproj", "{1E0B51E2-433B-498D-8246-C9F2A263A1EA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{B7A582E0-488F-4EB4-826A-BC0D13636B73}" + ProjectSection(SolutionItems) = preProject + .github\workflows\buid-api-web.yaml = .github\workflows\buid-api-web.yaml + .github\workflows\buid-api-messagebus.yaml = .github\workflows\buid-api-messagebus.yaml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/Server.Controllers.Api.MessageBus/Dockerfile b/src/Server.Controllers.Api.MessageBus/Dockerfile index abe5e6b..c5c1a7f 100644 --- a/src/Server.Controllers.Api.MessageBus/Dockerfile +++ b/src/Server.Controllers.Api.MessageBus/Dockerfile @@ -1,10 +1,12 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +ARG BUILDPLATFORM 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 BUILDPLATFORM ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY Directory.Build.props . diff --git a/src/Server.Controllers.Api.Web/Dockerfile b/src/Server.Controllers.Api.Web/Dockerfile index 1070dac..b1704c9 100644 --- a/src/Server.Controllers.Api.Web/Dockerfile +++ b/src/Server.Controllers.Api.Web/Dockerfile @@ -1,10 +1,12 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +ARG BUILDPLATFORM 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 BUILDPLATFORM ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY Directory.Build.props .