Skip to content

Commit d2406d7

Browse files
committed
Initial commit
0 parents  commit d2406d7

5 files changed

Lines changed: 163 additions & 0 deletions

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
README.md
3+
LICENSE

.github/workflows/docker-build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Push Container Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
schedule:
10+
# Rebuild weekly to pick up security updates from base image
11+
- cron: "37 4 * * 0"
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to GitHub Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{major}}.{{minor}}
48+
type=ref,event=branch
49+
type=sha,prefix=
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM debian:bookworm
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
# Install base system packages
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
ca-certificates \
8+
curl \
9+
wget \
10+
gnupg \
11+
git \
12+
git-lfs \
13+
openssh-client \
14+
sudo \
15+
# Utilities used by workflows
16+
jq \
17+
tar \
18+
gzip \
19+
xz-utils \
20+
unzip \
21+
zip \
22+
# Build toolchain (Rust, C/C++ projects)
23+
build-essential \
24+
pkg-config \
25+
libssl-dev \
26+
libudev-dev \
27+
# Container image builds
28+
buildah \
29+
fuse-overlayfs \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
# Install Node.js 24 via NodeSource
33+
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
34+
&& apt-get install -y --no-install-recommends nodejs \
35+
&& rm -rf /var/lib/apt/lists/*
36+
37+
# Configure buildah for containerized usage (vfs driver, no overlay-on-overlay)
38+
RUN mkdir -p /etc/containers /var/lib/containers/storage /run/containers/storage \
39+
&& printf '[storage]\ndriver = "vfs"\nrunroot = "/run/containers/storage"\ngraphroot = "/var/lib/containers/storage"\n' \
40+
> /etc/containers/storage.conf
41+
42+
# Allow unqualified image names to resolve (v2 registries.conf format)
43+
RUN printf 'unqualified-search-registries = ["docker.io"]\n' \
44+
> /etc/containers/registries.conf

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Custom Forgejo Runner Image
2+
3+
Docker image for Forgejo Actions runners, based on `debian:bookworm` with tools pre-installed to avoid repeated `apt-get install` in every job.
4+
5+
## What's included
6+
7+
| Category | Packages |
8+
|----------|----------|
9+
| **Runtime** | Node.js 24 (via NodeSource) |
10+
| **VCS** | git, git-lfs, openssh-client |
11+
| **Build tools** | build-essential, pkg-config, libssl-dev, libudev-dev |
12+
| **Container builds** | buildah (pre-configured with vfs storage driver), fuse-overlayfs |
13+
| **Utilities** | curl, wget, jq, tar, gzip, xz-utils, unzip, zip, sudo, ca-certificates |
14+
15+
## Usage
16+
17+
Pull the image from GitHub Container Registry:
18+
19+
```
20+
ghcr.io/systemscape/custom-forgejo-runner:latest
21+
```
22+
23+
Or build locally:
24+
25+
```sh
26+
just build
27+
```
28+
29+
## Runner configuration
30+
31+
In your Forgejo runner config, set labels to map workflow `runs-on` values to this image:
32+
33+
```yaml
34+
labels:
35+
- "docker:docker://ghcr.io/systemscape/custom-forgejo-runner:latest"
36+
- "debian-latest:docker://ghcr.io/systemscape/custom-forgejo-runner:latest"
37+
- "ubuntu-latest:docker://ghcr.io/systemscape/custom-forgejo-runner:latest"
38+
```
39+
40+
If you build locally instead, replace the image reference with `docker://localhost/forgejo-runner`.
41+
42+
Each label follows the format `<name>:docker://<image>`. When a workflow specifies `runs-on: ubuntu-latest`, the runner picks the matching label and starts a container from the configured image.
43+
44+
## Extending
45+
46+
Add packages to the `Dockerfile` and rebuild. For tools that are only needed by a single workflow, consider installing them in the workflow step instead to keep the base image lean.
47+
48+
### Rust toolchain
49+
50+
Rust is **not** pre-installed since [`dtolnay/rust-toolchain`](https://github.com/dtolnay/rust-toolchain) handles version pinning per-repo. The build toolchain (`build-essential`, `libssl-dev`, etc.) is included so Rust compilation works out of the box once the toolchain is installed.
51+
52+
### Buildah
53+
54+
Buildah is pre-installed and configured with the `vfs` storage driver (overlay-on-overlay is not supported inside containers). Workflows no longer need the `apt-get install buildah` + storage config boilerplate.

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Build the custom Forgejo runner image locally
2+
build:
3+
podman build -t forgejo-runner .

0 commit comments

Comments
 (0)