Skip to content

Commit

Permalink
add docker build job
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Feb 22, 2024
1 parent fb0996f commit 768e9fd
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Docker Image CI

on:
push:
paths:
- 'src/**'
- '.github/workflows/**'
branches: [ main ]
pull_request:
paths:
- 'src/**'
- '.github/workflows/**'
branches: [ main ]

jobs:
build-api:

runs-on: ubuntu-latest
env:
working-directory: ./src/Nager.PublicSuffixService

permissions:
contents: read
packages: read

steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore
working-directory: ${{env.working-directory}}
- name: Build
run: dotnet build --no-restore --configuration Release
working-directory: ${{env.working-directory}}
- name: Publish
run: dotnet publish --no-restore --configuration Release --output publish
working-directory: ${{env.working-directory}}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: api
# Directory containing files to upload
path: ${{env.working-directory}}/publish/
# Days before delete
retention-days: 1

build-docker:

needs: [build-api]
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: api
path: publish
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./src/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:latest
9 changes: 9 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-jammy-chiseled-amd64

# Listen ports
EXPOSE 8080

# Copy files from other build jobs
COPY publish .

ENTRYPOINT ["dotnet", "Nager.PublicSuffixService.dll"]

0 comments on commit 768e9fd

Please sign in to comment.