finally getting access to the docker socket

This commit is contained in:
2025-01-28 18:22:43 +01:00
parent adf1a97b9a
commit a909f2f1e7
5 changed files with 39 additions and 6 deletions

View File

@ -1,4 +1,10 @@
RECIPE=forgejo-runner
CACHE_ENABLED=false
# Defines the number of concrurrent tasks to be run
RUNNER_CAPACITY=1
# Set to 'host', to use the host network. When left empty it creates a temporary
# network for each container.
#CONTAIER_NETWORK

View File

@ -11,3 +11,30 @@ The forgejo runner needs to be registered at the forgejo instance. For that see
```
abra app cmd --chaos <app> app register_runner <host> <name> <token>
```
## Enabling caching
To enable [caching](https://forgejo.org/docs/latest/admin/runner-installation/#cache-configuration) set `CACHE_ENABLED` to `true`:
```
CACHE_ENABLED=true
```
## Docker in Docker
To give an action container the ability to create more docker containers (e.g. for tests) you need to set the container network to "host". This can be done in the `.env` file:
```
CONTAINER_NETWORK=host
```
This allows you to access the docker host at "tcp://0.0.0.0:2375". See this part of an action workflow on how to access the docker host.
```
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
endpoint: tcp://0.0.0.0:2375
platforms: linux/amd64
- name: run api tests
run: |
export DOCKER_HOST="tcp://0.0.0.0:2375"
make test-api
```

View File

@ -1,5 +1,5 @@
export RUNNER_CONF_VERSION=v6
export ENTRYPOINT_VERSION=v7
export RUNNER_CONF_VERSION=v7
export ENTRYPOINT_VERSION=v9
register_runner() {
forgejo-runner register --config /config.yml --no-interactive --token "$3" --name "$2" --instance "$1"

View File

@ -32,10 +32,10 @@ runner:
cache:
# Enable cache server to use actions/cache.
enabled: true
enabled: {{ env "CACHE_ENABLED" }}
# The directory to store the cache data.
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
dir: "/data/.cache"
dir: ""
# The host of the cache server.
# It's not for the address to listen, but the address to connect from job containers.
# So 0.0.0.0 is a bad choice, leave it empty to detect automatically.
@ -48,7 +48,7 @@ container:
# Specifies the network to which the container will connect.
# Could be host, bridge or the name of a custom network.
# If it's empty, create a network automatically.
network: ""
network: "{{ env "CONTAINER_NETWORK" }}"
# Whether to create networks with IPv6 enabled. Requires the Docker daemon to be set up accordingly.
# Only takes effect if "network" is set to "".
enable_ipv6: false

View File

@ -7,7 +7,7 @@ touch /data/.runner
mkdir -p /data/.cache
# Wait for the runner to get registered before starting the forgejo-runner daemon.
while [ ! -f /data/.runner ]
while [ ! -s /data/.runner ]
do
echo "The runner was not registered yet. Next try in 5 seconds."
sleep 5