Skip to content

Commit

Permalink
Add Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
HMBSbige committed Feb 10, 2024
1 parent 0a706ed commit ce0c364
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
45 changes: 44 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,51 @@ jobs:
dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NuGetAPIKey }} --skip-duplicate
dotnet nuget push *.snupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NuGetAPIKey }} --skip-duplicate
docker:
needs: [check_format, test]
runs-on: ubuntu-latest
permissions:
packages: write
env:
ProjectName: fakea2sserver
Owner: hmbsbige

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
uses: docker/build-push-action@v5
with:
push: false
tags: ghcr.io/${{ env.Owner }}/${{ env.ProjectName }}:master
platforms: linux/amd64,linux/arm64

- name: Push
uses: docker/build-push-action@v5
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
with:
push: true
tags: |
ghcr.io/${{ env.Owner }}/${{ env.ProjectName }}:${{ github.ref_name }}
ghcr.io/${{ env.Owner }}/${{ env.ProjectName }}:latest
platforms: linux/amd64,linux/arm64

release:
needs: build
needs: [build, docker]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
2 changes: 2 additions & 0 deletions A2SService.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\Unit
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{41CD9BD9-5437-40D2-A8F1-D3CCB5AA8AA9}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
.editorconfig = .editorconfig
.gitignore = .gitignore
common.props = common.props
Dockerfile = Dockerfile
LICENSE = LICENSE
NuGet.Config = NuGet.Config
README.md = README.md
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0-cbl-mariner-distroless AS base
USER app
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0-cbl-mariner AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY . .
WORKDIR "/src/FakeA2SServer"
RUN dotnet build "FakeA2SServer.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "FakeA2SServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "FakeA2SServer.dll"]

0 comments on commit ce0c364

Please sign in to comment.