Skip to content

Commit

Permalink
add docker build chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Spiritreader committed Aug 30, 2024
1 parent 1fd6496 commit 7a02d9c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.pdb
*.Development.json
**bin
**obj
34 changes: 34 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker
on: push
jobs:
docker:
name: GitHub Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/walzen-group/BeatTogether.UnifiedServer/beat-together-unified-server
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@v2
- uses: docker/build-push-action@v4
with:
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Stage 1: Build the .NET application
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app

# Copy everything from the host machine into the container
COPY . .

RUN dotnet clean BeatTogether.UnifiedServer.sln -c Release

# Build for linux x64 for now (no multiarch support yet)
RUN dotnet publish BeatTogether.UnifiedServer.sln -p:PublishReadyToRun=true -p:PublishTrimmed=false -p:TargetFramework=net6.0 -r linux-x64 -o /tmp/out

# Stage 2: Create a new runtime container
# FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime

WORKDIR /app

# Copy the published output from the build stage
COPY --from=build /tmp/out /app

ENTRYPOINT ["/app/BeatTogether.UnifiedServer"]

0 comments on commit 7a02d9c

Please sign in to comment.