Skip to content

Publish Docker Images #5

Publish Docker Images

Publish Docker Images #5

Workflow file for this run

name: Publish Docker Images
on:
release:
types: [ published ]
permissions:
packages: read
jobs:
docker-linux:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- { name: "DragonFruit.OnionFruit.Web", tag-prefix: "" }
- { name: "DragonFruit.OnionFruit.Web.Worker", tag-prefix: "worker-" }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup GitHub NuGet
run: dotnet nuget update source dragonfruit --username USERNAME --password ${{ github.token }} --store-password-in-clear-text
- name: Build
run: dotnet publish -c Release -p:UseAppHost=false -p:Version=${{ github.event.release.tag_name }} ${{ matrix.project.name }}
- name: Image Build and Push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.project.name }}/bin/Release/net8.0/publish
tags: dragonfruitdotnet/onionfruit-web:${{ matrix.project.tag-prefix }}linux
platforms: linux/arm64,linux/amd64
file: ${{ matrix.project.name }}/Dockerfile
push: true
docker-windows:
runs-on: windows-latest
strategy:
matrix:
project:
- { name: "DragonFruit.OnionFruit.Web", tag-prefix: "" }
- { name: "DragonFruit.OnionFruit.Web.Worker", tag-prefix: "worker-" }
env:
DOCKER_TAG: dragonfruitdotnet/onionfruit-web:${{ matrix.project.tag-prefix }}windows
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup GitHub NuGet
run: dotnet nuget update source github --username USERNAME --password ${{ github.token }} --store-password-in-clear-text
- name: Build
run: dotnet publish -c Release -p:UseAppHost=false -p:Version=${{ github.event.release.tag_name }} ${{ matrix.project.name }}
- name: Image Build
run: docker build -f ${{ matrix.project.name }}\Dockerfile -t ${{ env.DOCKER_TAG }} --build-arg "IMAGEVARIANT=nanoserver-ltsc2022" ${{ matrix.project.name }}\bin\Release\net8.0\publish
- name: Image Push
run: docker push ${{ env.DOCKER_TAG }}
docker-multiarch-image:
runs-on: ubuntu-latest
needs:
- docker-linux
- docker-windows
steps:
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create MultiArch+MultiOS Manifest (Server)
run: docker buildx imagetools create -t dragonfruitdotnet/onionfruit-web -t dragonfruitdotnet/onionfruit-web:${{ github.event.release.tag_name }} dragonfruitdotnet/onionfruit-web:windows dragonfruitdotnet/onionfruit-web:linux
- name: Create MultiArch+MultiOS Manifest (Worker)
run: docker buildx imagetools create -t dragonfruitdotnet/onionfruit-web:worker -t dragonfruitdotnet/onionfruit-web:worker-${{ github.event.release.tag_name }} dragonfruitdotnet/onionfruit-web:worker-windows dragonfruitdotnet/onionfruit-web:worker-linux