Skip to content

Fix docker image

Fix docker image #164

Workflow file for this run

name: .NET
on:
push:
branches: [ master ]
paths:
- .github/workflows/dotnet.yml
- backend/**
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
packages: write
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
mysql:
image: mariadb:11.3.2
env:
MYSQL_ROOT_PASSWORD: naheulbook
ports:
- 3306
options: --health-cmd="healthcheck.sh --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Set up MySQL
run: |
mysql --port ${{ job.services.mysql.ports['3306'] }} --host 127.0.0.1 -u root --password=naheulbook <<'EOF'
CREATE DATABASE `naheulbook_test` CHARACTER SET UTF8 COLLATE utf8_general_ci;
CREATE USER 'naheulbook_test'@'%' IDENTIFIED BY 'naheulbook';
GRANT ALL PRIVILEGES ON `naheulbook_test`.* TO 'naheulbook_test'@'%';
CREATE DATABASE `naheulbook_integration` CHARACTER SET UTF8 COLLATE utf8_general_ci;
CREATE USER 'naheulbook'@'%' IDENTIFIED BY 'naheulbook';
GRANT ALL PRIVILEGES ON `naheulbook_integration`.* TO 'naheulbook'@'%';
FLUSH PRIVILEGES;
EOF
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: backend
- name: Build
run: dotnet build --no-restore -c Release
working-directory: backend
- name: Test
run: dotnet test --no-build --verbosity normal --logger junit -c Release
working-directory: backend
env:
FORCE_COLOR: true
TERM: xterm
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
- name: Publish Unit Test Results
uses: EnricoMi/[email protected]
if: always()
with:
files: "backend/tests/*/TestResults/TestResults.xml"
continue-on-error: true
- name: Publish Naheulbook.Web
run: dotnet publish --no-restore --no-build -c Release ./backend/src/Naheulbook.Web/Naheulbook.Web.csproj
- name: Publish Naheulbook.DatabaseMigrator.Cli
run: dotnet publish --no-restore --no-build -c Release ./backend/tools/Naheulbook.DatabaseMigrator.Cli/Naheulbook.DatabaseMigrator.Cli.csproj
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker - Web
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract metadata (tags, labels) for Docker - Db migrator
id: meta-db-migrator
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-db-migrator
- name: Build and push Docker - Web
uses: docker/build-push-action@v3
with:
context: backend/src/Naheulbook.Web/bin/Release/publish/
file: backend/src/Naheulbook.Web/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker - Db migrator
uses: docker/build-push-action@v3
with:
context: backend/tools/Naheulbook.DatabaseMigrator.Cli/bin/Release/publish/
file: backend/tools/Naheulbook.DatabaseMigrator.Cli/Dockerfile
push: true
tags: ${{ steps.meta-db-migrator.outputs.tags }}
labels: ${{ steps.meta-db-migrator.outputs.labels }}