Skip to content

Commit

Permalink
Add build pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
oveldman committed Jul 21, 2024
1 parent dd03c34 commit 7a4451c
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 4 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/buid-api-messagebus.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
48 changes: 48 additions & 0 deletions .github/workflows/buid-api-web.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
6 changes: 6 additions & 0 deletions MadWorldNL.CloudPlayground.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/Server.Controllers.Api.MessageBus/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 .
Expand Down
6 changes: 4 additions & 2 deletions src/Server.Controllers.Api.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 .
Expand Down

0 comments on commit 7a4451c

Please sign in to comment.