further initialising
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
.direnv/
|
||||
.envrc
|
||||
|
||||
result
|
||||
result-*
|
||||
|
||||
47
CLAUDE.md
Normal file
47
CLAUDE.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Nix Image Builder Project Guide
|
||||
|
||||
## Project Information
|
||||
- **Description**: Docker image builder for Gitea Actions runner with Nix support
|
||||
- **Primary use case**: Running Gitea Actions in a Kubernetes cluster
|
||||
|
||||
## Common Commands
|
||||
|
||||
### Building
|
||||
```bash
|
||||
# Build the Docker image
|
||||
just build
|
||||
|
||||
# Load the image into Docker
|
||||
just load
|
||||
|
||||
# Build and load in one step
|
||||
just build-load
|
||||
```
|
||||
|
||||
### Testing
|
||||
```bash
|
||||
# Run tests
|
||||
just test
|
||||
```
|
||||
|
||||
### Code Formatting
|
||||
```bash
|
||||
# Format code
|
||||
just fmt
|
||||
```
|
||||
|
||||
### Development
|
||||
```bash
|
||||
# Start a development shell
|
||||
nix develop
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
- `flake.nix` - Main Nix configuration file for the project
|
||||
- `justfile` - Task runner configuration
|
||||
- `treefmt.nix` - Code formatting configuration
|
||||
|
||||
## Key Dependencies
|
||||
- Nix package manager
|
||||
- Docker
|
||||
- Just command runner
|
||||
58
README.md
58
README.md
@@ -1,5 +1,57 @@
|
||||
Nix image builder
|
||||
# Nix Image Builder for Gitea Actions Runner
|
||||
|
||||
---
|
||||
A Docker image builder for creating a Gitea Actions runner that includes Nix package manager and essential tools.
|
||||
|
||||
Builds a docker image built off the ubuntu-latest gitea act runner that I can use for building with nix with stuff cached.
|
||||
## Purpose
|
||||
|
||||
This project builds a Docker image that can be used as a Gitea Actions runner in a Kubernetes cluster. It comes with Nix pre-installed and configured, allowing for reproducible builds and consistent CI environments.
|
||||
|
||||
## Features
|
||||
|
||||
- Based on Nix's pure Docker image
|
||||
- Includes Nix package manager
|
||||
- Contains essential development tools (git, curl, etc.)
|
||||
- Docker-in-Docker capability for container builds
|
||||
- Optimized for Kubernetes deployment
|
||||
|
||||
## Usage
|
||||
|
||||
### Build the image
|
||||
|
||||
```bash
|
||||
# Build the Docker image
|
||||
just build
|
||||
|
||||
# Load the image into Docker
|
||||
just load
|
||||
|
||||
# Or do both in one step
|
||||
just build-load
|
||||
```
|
||||
|
||||
### Running the image
|
||||
|
||||
To run the image locally for testing:
|
||||
|
||||
```bash
|
||||
docker run -it --rm gitea-act-runner:latest
|
||||
```
|
||||
|
||||
### Deploying to Kubernetes
|
||||
|
||||
The image is designed to be used as a Gitea Actions runner in a Kubernetes cluster. You can configure your Gitea instance to use this runner for CI/CD pipelines.
|
||||
|
||||
## Development
|
||||
|
||||
This project uses the Nix flake system for development. Make sure you have Nix installed with flakes enabled.
|
||||
|
||||
```bash
|
||||
# Enter development shell
|
||||
nix develop
|
||||
|
||||
# Run formatter
|
||||
just fmt
|
||||
|
||||
# Run tests
|
||||
just test
|
||||
```
|
||||
|
||||
55
flake.nix
55
flake.nix
@@ -6,8 +6,7 @@
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, ... }@inputs:
|
||||
outputs = { self, nixpkgs, ... }@inputs:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
pkgsFor =
|
||||
@@ -24,11 +23,59 @@
|
||||
# nix fmt formatter
|
||||
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
|
||||
|
||||
# default devshell
|
||||
# Docker image for Gitea Actions runner
|
||||
packages = eachSystem (pkgs: {
|
||||
default = self.packages.${pkgs.system}.act-runner-image;
|
||||
|
||||
act-runner-image = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "nix-gitea-act-runner";
|
||||
tag = "latest";
|
||||
|
||||
# fromImage = "ghcr.io/catthehacker/ubuntu:runner-latest";
|
||||
|
||||
contents = [
|
||||
# Base packages
|
||||
pkgs.bash
|
||||
pkgs.coreutils
|
||||
pkgs.nix
|
||||
pkgs.cacert
|
||||
pkgs.curl
|
||||
pkgs.git
|
||||
pkgs.gnutar
|
||||
pkgs.gzip
|
||||
pkgs.gnused
|
||||
pkgs.gnugrep
|
||||
|
||||
# runner
|
||||
pkgs.gitea-actions-runner
|
||||
|
||||
|
||||
# Additional tools
|
||||
pkgs.docker
|
||||
pkgs.docker-compose
|
||||
pkgs.jq
|
||||
];
|
||||
|
||||
config = {
|
||||
Cmd = [ "/bin/bash" ];
|
||||
Env = [
|
||||
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
|
||||
"NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
|
||||
"PATH=/bin"
|
||||
];
|
||||
WorkingDir = "/workspace";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
# default devshell
|
||||
devShells = eachSystem (pkgs: {
|
||||
default = pkgs.mkShell {
|
||||
packages = [ pkgs.just ];
|
||||
packages = [
|
||||
pkgs.just
|
||||
pkgs.docker
|
||||
pkgs.docker-compose
|
||||
];
|
||||
|
||||
# Will be executed before entering the shell
|
||||
# or running a command
|
||||
|
||||
24
justfile
24
justfile
@@ -14,10 +14,30 @@ test:
|
||||
nix flake check
|
||||
# uv run ruff check src tests
|
||||
|
||||
#
|
||||
|
||||
# format code
|
||||
fmt:
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
nix fmt
|
||||
|
||||
# build docker image
|
||||
build:
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
nix build .#act-runner-image
|
||||
|
||||
# load the image into docker
|
||||
load:
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
docker load < result
|
||||
|
||||
# build and load in one step
|
||||
build-load: build load
|
||||
echo "Image loaded successfully!"
|
||||
|
||||
# print image information
|
||||
info:
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
docker inspect gitea-act-runner:latest
|
||||
|
||||
Reference in New Issue
Block a user