This commit is contained in:
commit
4123ec4ef3
28
.gitea/workflows/docker-build.yml
Normal file
28
.gitea/workflows/docker-build.yml
Normal file
@ -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
|
||||
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@ -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
|
||||
76
README.md
Normal file
76
README.md
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user