Skip to content

Commit 274a932

Browse files
author
nold
committed
feat(ci): add github action - by qwen3.6-30b-a3b
1 parent ab9eba3 commit 274a932

2 files changed

Lines changed: 147 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: build
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
push:
7+
branches: [master]
8+
schedule:
9+
- cron: '0 0 * * 0' # weekly
10+
workflow_dispatch:
11+
12+
env:
13+
REGISTRY_DOCKER: docker.io
14+
REGISTRY_GHCR: ghcr.io
15+
IMAGE_NAME_DOCKER: nold360/borgserver
16+
IMAGE_NAME_GHCR: ghcr.io/nold360/borgserver
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- base: debian:trixie-slim
26+
tags: |
27+
trixie
28+
latest
29+
platforms: linux/amd64,linux/arm64
30+
- base: debian:bookworm-slim
31+
tags: |
32+
bookworm
33+
platforms: linux/amd64,linux/arm64
34+
- base: debian:unstable-slim
35+
tags: |
36+
unstable
37+
platforms: linux/amd64,linux/arm64
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Docker meta
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: |
48+
${{ env.REGISTRY_DOCKER }}/${{ env.IMAGE_NAME_DOCKER }}
49+
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME_GHCR }}
50+
tags: ${{ matrix.tags }}
51+
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
58+
- name: Dry-run build
59+
if: github.event_name == 'pull_request'
60+
uses: docker/build-push-action@v6
61+
with:
62+
context: .
63+
platforms: ${{ matrix.platforms }}
64+
push: false
65+
tags: ${{ steps.meta.outputs.tags }}
66+
build-args: |
67+
BASE_IMAGE=${{ matrix.base }}
68+
69+
- name: Login to Docker Hub
70+
if: github.event_name != 'pull_request'
71+
uses: docker/login-action@v3
72+
with:
73+
username: ${{ secrets.DOCKER_USERNAME }}
74+
password: ${{ secrets.DOCKER_PASSWORD }}
75+
76+
- name: Login to GHCR
77+
if: github.event_name != 'pull_request'
78+
uses: docker/login-action@v3
79+
with:
80+
registry: ghcr.io
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GH_PUSH_TOKEN }}
83+
84+
- name: Build and push
85+
if: github.event_name != 'pull_request'
86+
uses: docker/build-push-action@v6
87+
with:
88+
context: .
89+
platforms: ${{ matrix.platforms }}
90+
push: true
91+
tags: ${{ steps.meta.outputs.tags }}
92+
labels: ${{ steps.meta.outputs.labels }}
93+
build-args: |
94+
BASE_IMAGE=${{ matrix.base }}
95+
96+

CLAUDE.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Docker image for running a BorgBackup server. It builds a Debian-based container with openssh-daemon that accepts SSH key auth for borg clients. Each client SSH key in `/sshkeys/clients/` maps to a separate borg repository.
8+
9+
## Key Files
10+
11+
- `Dockerfile` - Builds the image from `debian:<version>-slim`, installs `borgbackup` + `openssh-server`
12+
- `data/run.sh` - Entrypoint script: adjusts PUID/PGID, generates SSH host keys, imports client keys into `authorized_keys` with restricted `borg serve` commands, starts sshd
13+
- `data/sshd_config` - Hardened SSH config: pubkey-only, no forwarding, no TTY, SFTP disabled
14+
- `.woodpecker.yml` - CI pipeline using Woodpecker CI with Docker Buildx for multi-platform builds
15+
- `docker-compose.yml` - Example compose file
16+
17+
## Architecture
18+
19+
The entrypoint (`run.sh`) works as follows:
20+
1. Adjusts `borg` user/group IDs to match host PUID/PGID
21+
2. Validates `/backup` and `/sshkeys` volumes exist and that at least one client key is present (sshd won't start otherwise)
22+
3. Generates SSH host keys (ed25519, rsa) in `/sshkeys/host/` if missing
23+
4. Iterates over files in `/sshkeys/clients/`, creating an `authorized_keys` entry per client with:
24+
- `restrict` flag + `command=` wrapping a `borg serve --restrict-to-path` command
25+
- If `BORG_ADMIN` is set, that client gets unrestricted access to all repos
26+
- If `BORG_APPEND_ONLY=yes`, non-admin clients get `--append-only`
27+
5. Starts `/usr/sbin/sshd -D -e`
28+
29+
## Environment Variables
30+
31+
| Variable | Default | Description |
32+
|---|---|---|
33+
| `BORG_APPEND_ONLY` | `no` | Restrict clients to append-only mode |
34+
| `BORG_ADMIN` | unset | Client key name that gets full access to all repos |
35+
| `BORG_SERVE_ARGS` | unset | Extra args passed to `borg serve` |
36+
| `PUID` | `1000` | User ID for `borg` user |
37+
| `PGID` | `1000` | Group ID for `borg` group |
38+
39+
## CI/CD
40+
41+
Built via Woodpecker CI (`.woodpecker.yml`). Matrix builds target:
42+
- `unstable-slim``linux/arm64/v8` tag `unstable`
43+
44+
Builds publish to Docker Hub (`nold360/borgserver`) and GHCR (`ghcr.io/nold360/borgserver`).
45+
46+
## Building Locally
47+
48+
```bash
49+
docker build -t borgserver:dev .
50+
docker build --build-arg BASE_IMAGE=debian:trixie-slim -t borgserver:trixie .
51+
```

0 commit comments

Comments
 (0)