diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..2640605 --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,32 @@ +name: Build and Push Docker Image to GHCR + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set repo owner to lowercase + run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image to GHCR + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/${{ env.REPO_OWNER }}/ragecoop-v:latest + dockerfile: Dockerfile \ No newline at end of file diff --git a/.gitignore b/.gitignore index 557da3d..43be543 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ **/obj **/packages **/.vs -**/.vscode \ No newline at end of file +**/.vscode +**/.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0bd0dcb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Use the official image as a parent image +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 + +# Use the SDK image to build the app +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env +WORKDIR /src + +# Copy csproj and restore as distinct layers +COPY RageCoop.Server/*.csproj ./RageCoop.Server/ +COPY libs/*.dll ./libs/ + +# Assuming RageCoop.Core is a dependency, if not, you can comment out the next line +COPY RageCoop.Core/*.csproj ./RageCoop.Core/ + +RUN dotnet restore RageCoop.Server/RageCoop.Server.csproj + +# Copy everything else and build +COPY . . +WORKDIR /src/RageCoop.Server +RUN dotnet publish -c Release -o /app + +# Build runtime image +FROM base AS final +WORKDIR /app +COPY --from=build-env /app . +ENTRYPOINT ["dotnet", "RageCoop.Server.dll"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6a57728 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.8' + +services: + ragecoop-v: + build: + context: . + dockerfile: Dockerfile + ports: + - "4499:4499/udp" + stdin_open: true + tty: true + volumes: + - ./Settings.xml:/app/Settings.xml