Add readme with documentation
All checks were successful
Build Docker Image on Commit / build-and-publish (push) Successful in 8s

Be warned, majority was made with AI, manually edited for acuracy and consistency
This commit is contained in:
Merith-TK 2024-12-25 05:50:38 +00:00
parent bd6aebbc8c
commit 95a86b62ef

View file

@ -1,36 +1,54 @@
# README for Docker Image Build and Publish Workflows # Forgejo Runner
## Overview The entrypoint script sets up and runs the `forgejo-runner`, including configuring the runner file and managing the registration process. The script supports custom configurations for Forgejo, Docker, and environment variables.
This repository contains two GitHub Actions workflows that automate the building and publishing of Docker images to an OCI registry. It is important to note that using the `command` docker flag will override the entrypoint *by design*, this is to make it compatible with older manual configurations
### Workflows ## Environment Variables
1. **On Commit to Main** ### Required Variables
- **Trigger:** Activates on commits to the `main` branch (tags are excluded).
- **Purpose:** Builds and publishes a Docker image for each commit.
2. **On Tag Push** > Only needed during registration of the runner.
- **Trigger:** Activates when a new tag is pushed. > After initial registration the runner operates off of the runner.
- **Purpose:** Builds and publishes a Docker image for the tag and tags it as `latest`. - **`FORGEJO_URL`**: The URL of the Forgejo instance. Default: `http://forgejo:3000` Only needed during registration of the runner.
- **`FORGEJO_SECRET`**: Secret used for Forgejo runner creation. Only needed during registration of the runner.
- **`RUNNER_TOKEN`**: Token used for runner registration. Only needed during registration of the runner.
## Prerequisites
- **Secrets Needed:** - **`RUNNER_NAME`** (Optional): Name for the runner. Default: The hostname of the container.
- `OCI_TOKEN`: Your OCI registry token.
- `OCI_USER`: Your OCI registry username. ### Optional Configuration Variables
- **`DEBUG`**: Enables debug logging. Default: `false`
## How to Use - **`RUNNER_FILE`**: Path to the runner file. Default: `runner.json`
- **`CONFIG_FILE`**: Path to the configuration file. Default: `/data/config.yml`
- **`ENV_FILE`**: Path to the environment file. Default: `/data/.env`
- **`RUNNER_LABELS`**: Labels to attach to the runner. Default:
- `docker:docker://code.forgejo.org/oci/node:20-bookworm`
- `ubuntu-22.04:docker://catthehacker/ubuntu:act-22.04`
1. **Clone the Repository:** Get a local copy of this repository. - **`DOCKER_HOST`**: Docker host URL. Default: `tcp://docker:2367`
2. **Modify Dockerfile:** Update the `Dockerfile` for your application. - **`DOCKER_CERT_PATH`**: Path to Docker certificates. Default: `/certs/client`
3. **Push Changes:** Push changes to the `main` branch or create a new tag. - **`DOCKER_TLS_VERIFY`**: Whether Docker TLS verification is enabled. Default: `1`
4. **Check Workflow Status:** View the Actions tab in Forgjo to monitor workflow runs. - **`DOCKER_PRIVILEGED`**: Whether to run the container in privileged mode. Default: `false`
- **`MAX_REG_ATTEMPTS`**: Maximum number of registration attempts. Default: `10`
- **`SKIP_WAIT`**: Whether to skip the wait before starting the runner. Default: `false`
## Notes ## Notes
- Ensure your Docker environment is compatible with multi-platform builds if necessary. - The entrypoint will automatically create and configure a `config.yml` file if it does not already exist.
- The runner will attempt to connect to the Forgejo instance and register the runner automatically.
- If `FORGEJO_SECRET` is not provided, the runner will use the `RUNNER_TOKEN` for registration.
- If the registration fails, the script will retry according to the `MAX_REG_ATTEMPTS` value.
## Troubleshooting
- **Invalid Configuration**: If the runner does not start, ensure that all required environment variables are set and that the configuration file is valid.
- **Network Issues**: Check your `DOCKER_HOST` and `DOCKER_CERT_PATH` to ensure that Docker is properly configured for secure communication.
## License ## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. This image is distributed under the MIT license. See the LICENSE file for more details.