From 4123ec4ef309eafc70dcdf5c4a1a1f62ac402dac Mon Sep 17 00:00:00 2001 From: Klas Broberg Date: Mon, 15 Sep 2025 13:30:18 +0200 Subject: [PATCH] Initial commit --- .gitea/workflows/docker-build.yml | 28 ++++++++++++ Dockerfile | 33 ++++++++++++++ README.md | 76 +++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 .gitea/workflows/docker-build.yml create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml new file mode 100644 index 0000000..0faa924 --- /dev/null +++ b/.gitea/workflows/docker-build.yml @@ -0,0 +1,28 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to Docker registry + uses: docker/login-action@v2 + with: + registry: git.pitan.net + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: git.pitan.net/${{ github.repository }}:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a95e64a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM docker.io/gitea/act_runner:latest + +# Switch to root to install packages +USER root + +# Update package lists and install prerequisites +RUN apt-get update && apt-get install -y \ + wget \ + apt-transport-https \ + software-properties-common \ + && rm -rf /var/lib/apt/lists/* + +# Add Microsoft package repository and install .NET SDK +RUN wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ + && dpkg -i packages-microsoft-prod.deb \ + && rm packages-microsoft-prod.deb \ + && apt-get update \ + && apt-get install -y dotnet-sdk-9.0 \ + && rm -rf /var/lib/apt/lists/* + +# Verify .NET installation +RUN dotnet --version + +# Switch back to the original user (if act_runner has a specific user) +# Check what user the base image uses +RUN id + +# Set environment variables for .NET +ENV DOTNET_ROOT=/usr/share/dotnet +ENV PATH=$PATH:/usr/share/dotnet + +# Keep the original entrypoint from act_runner +# The base image will handle the act_runner functionality diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c245ed --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# Gitea .NET Runner Docker Image + +This project creates a Docker image that extends the `gitea/act_runner:latest` base image with the latest .NET SDK installed. + +## Overview + +The Docker image includes: +- Base: `gitea/act_runner:latest` - Gitea Actions runner +- .NET SDK 9.0 (latest) - For building and running .NET applications +- All dependencies required for .NET development + +## Files + +- `Dockerfile` - Docker image definition +- `build.sh` - Script to build the Docker image +- `push.sh` - Script to push the image to your local Gitea registry +- `README.md` - This documentation + +## Usage + +### Building the Image + +```bash +./build.sh +``` + +This will: +1. Build the Docker image locally as `gitea-dotnet-runner:latest` +2. Tag it for your Gitea registry as `git.pitan.net/klas/gitea-dotnet-runner:latest` + +### Pushing to Gitea Registry + +```bash +./push.sh +``` + +This will: +1. Login to your Gitea registry (you'll be prompted for credentials) +2. Push the image to `git.pitan.net/klas/gitea-dotnet-runner:latest` + +### Using the Image + +Once pushed to your Gitea registry, you can use this image in your Gitea Actions workflows: + +```yaml +name: .NET Build +on: [push] + +jobs: + build: + runs-on: self-hosted + container: git.pitan.net/klas/gitea-dotnet-runner:latest + steps: + - uses: actions/checkout@v4 + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal +``` + +## Configuration + +The scripts use these default values: +- Image name: `gitea-dotnet-runner` +- Registry: `git.pitan.net` +- Username: `klas` + +You can modify these values in the `build.sh` and `push.sh` scripts if needed. + +## Requirements + +- Docker installed and running +- Access to your Gitea registry at `git.pitan.net` +- Internet connection for downloading base images and .NET SDK