Skip to content

Commit b9b4957

Browse files
committed
initial commit
Signed-off-by: kpango <kpango@vdaas.org>
0 parents  commit b9b4957

305 files changed

Lines changed: 56193 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Read(//home/kpango/.claude/**)",
5+
"Read(//home/kpango/.config/**)",
6+
"Read(//home/kpango/.local/share/**)",
7+
"Read(//home/kpango/**)",
8+
"Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\({k: '***' if 'token' in k.lower\\(\\) or 'key' in k.lower\\(\\) or 'secret' in k.lower\\(\\) else v for k,v in d.items\\(\\)}\\)\")",
9+
"Bash(nix search *)",
10+
"Bash(curl -s \"https://api.github.com/repos/containerd/containerd/releases/latest\")",
11+
"Bash(curl -s \"https://api.github.com/repos/slimtoolkit/slim/releases/latest\")",
12+
"Bash(curl -sL \"https://github.com/containerd/containerd/releases/download/v2.3.0/containerd-2.3.0-linux-amd64.tar.gz\")",
13+
"Bash(tar tzf *)",
14+
"Bash(curl -sL \"https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz\")",
15+
"Bash(make format/zsh)",
16+
"Bash(nix eval *)",
17+
"Bash(make perm *)",
18+
"Bash(git *)"
19+
]
20+
}
21+
}

.github/actions/docker/action.yaml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: "Docker Action"
2+
description: "Build or Merge Docker images using the repository's Makefile."
3+
inputs:
4+
operation:
5+
description: "The operation to perform (build or merge)"
6+
required: true
7+
image_name:
8+
description: "The image name to build or merge"
9+
required: true
10+
docker_user:
11+
description: "DockerHub username"
12+
required: true
13+
default: "kpango"
14+
docker_pass:
15+
description: "DockerHub password"
16+
required: true
17+
github_token:
18+
description: "GitHub Token"
19+
required: true
20+
docker_push:
21+
description: "Whether this is a push build"
22+
required: false
23+
default: "false"
24+
platform:
25+
description: "The platform to build"
26+
required: false
27+
suffix:
28+
description: "The suffix for the docker tag"
29+
required: false
30+
ghcr_user:
31+
description: "GHCR username"
32+
required: false
33+
default: ${{ github.repository_owner }}
34+
35+
runs:
36+
using: "composite"
37+
steps:
38+
- name: Login to DockerHub
39+
if: inputs.operation == 'merge' || inputs.docker_push == 'true'
40+
uses: docker/login-action@v4
41+
with:
42+
username: ${{ inputs.docker_user }}
43+
password: ${{ inputs.docker_pass }}
44+
45+
- name: Login to GitHub Container Registry
46+
if: inputs.operation == 'merge' || inputs.docker_push == 'true'
47+
uses: docker/login-action@v4
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.actor }}
51+
password: ${{ inputs.github_token }}
52+
53+
- name: Clean up Docker Data
54+
if: inputs.operation == 'build'
55+
shell: bash
56+
run: |
57+
docker system prune -a -f --volumes
58+
docker buildx prune -a -f
59+
60+
- name: Create Buildx
61+
if: inputs.operation == 'build'
62+
shell: bash
63+
env:
64+
GITHUB_ACCESS_TOKEN: ${{ inputs.github_token }}
65+
DOCKER_BUILDER_PLATFORM: ${{ inputs.platform }}
66+
IMAGE_NAME: ${{ inputs.image_name }}
67+
run: |
68+
GC_FLAG="false"
69+
CACHE_MODE="max"
70+
WORKERS="8"
71+
72+
# large images: enable GC so BuildKit frees memory during build
73+
if [[ "$IMAGE_NAME" == "go" || "$IMAGE_NAME" == "rust" || "$IMAGE_NAME" == "env" || "$IMAGE_NAME" == "nix" || "$IMAGE_NAME" == "tools" || "$IMAGE_NAME" == "vald" ]]; then
74+
GC_FLAG="true"
75+
fi
76+
77+
# images with huge intermediate layers: use min cache to avoid OOM on export
78+
if [[ "$IMAGE_NAME" == "nix" || "$IMAGE_NAME" == "rust" || "$IMAGE_NAME" == "vald" ]]; then
79+
CACHE_MODE="min"
80+
fi
81+
82+
# nix: single bottleneck stage, cmake vald: CPU-bound — cap workers to save memory
83+
if [[ "$IMAGE_NAME" == "nix" || "$IMAGE_NAME" == "vald" ]]; then
84+
WORKERS="4"
85+
fi
86+
87+
echo "DOCKER_CACHE_MODE=${CACHE_MODE}" >> "$GITHUB_ENV"
88+
echo "DOCKER_BUILDX_WORKERS=${WORKERS}" >> "$GITHUB_ENV"
89+
90+
make \
91+
DOCKER_BUILDER_PLATFORM="$DOCKER_BUILDER_PLATFORM" \
92+
GITHUB_ACCESS_TOKEN="$GITHUB_ACCESS_TOKEN" \
93+
DOCKER_BUILDX_GC="$GC_FLAG" \
94+
DOCKER_BUILDX_WORKERS="$WORKERS" \
95+
docker/builder/create
96+
97+
- name: Run Makefile target
98+
shell: bash
99+
env:
100+
OPERATION: ${{ inputs.operation }}
101+
IMAGE_NAME: ${{ inputs.image_name }}
102+
USER_DEFAULT: ${{ inputs.docker_user }}
103+
GHCR_USER: ${{ inputs.ghcr_user }}
104+
DOCKER_PUSH: ${{ inputs.docker_push }}
105+
GITHUB_ACCESS_TOKEN: ${{ inputs.github_token }}
106+
DOCKER_BUILDER_PLATFORM: ${{ inputs.platform }}
107+
DOCKER_ARCH_SUFFIX: ${{ inputs.suffix }}
108+
DOCKER_CACHE_MODE: ${{ env.DOCKER_CACHE_MODE }}
109+
EVENT_NAME: ${{ github.event_name }}
110+
EVENT_PATH: ${{ github.event_path }}
111+
GITHUB_REF_VAR: ${{ github.ref }}
112+
run: |
113+
VERSION="nightly"
114+
EXTRA_OPTS=""
115+
TARGET="docker/${OPERATION}/${IMAGE_NAME}"
116+
117+
if [ "$EVENT_NAME" == "pull_request" ]; then
118+
PR_NUM=$(jq -r ".number" "$EVENT_PATH")
119+
VERSION="pr-$PR_NUM"
120+
elif [[ "$GITHUB_REF_VAR" == refs/tags/* ]]; then
121+
VERSION="${GITHUB_REF_VAR#refs/tags/}"
122+
fi
123+
124+
if [ "$EVENT_NAME" == "schedule" ]; then
125+
EXTRA_OPTS="--no-cache"
126+
fi
127+
128+
if [ "$OPERATION" == "build" ]; then
129+
make \
130+
DOCKER_PUSH="$DOCKER_PUSH" \
131+
USER="$USER_DEFAULT" \
132+
SYS_USER="$USER_DEFAULT" \
133+
USER_ID="1000" \
134+
GROUP_ID="1000" \
135+
GROUP_IDS="1000 98 972 987 994 996 998 1001 1002 1003 1004 1005" \
136+
GHCR_USER="$GHCR_USER" \
137+
VERSION="$VERSION" \
138+
GITHUB_ACCESS_TOKEN="$GITHUB_ACCESS_TOKEN" \
139+
DOCKER_BUILDER_PLATFORM="$DOCKER_BUILDER_PLATFORM" \
140+
DOCKER_ARCH_SUFFIX="$DOCKER_ARCH_SUFFIX" \
141+
DOCKER_CACHE_MODE="${DOCKER_CACHE_MODE:-max}" \
142+
DOCKER_EXTRA_OPTS="$EXTRA_OPTS" \
143+
"$TARGET"
144+
else
145+
make \
146+
USER="$USER_DEFAULT" \
147+
GHCR_USER="$GHCR_USER" \
148+
VERSION="$VERSION" \
149+
"$TARGET"
150+
fi

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: "Build docker images"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- "*.*.*"
8+
- "v*.*.*"
9+
- "*.*.*-*"
10+
- "v*.*.*-*"
11+
paths:
12+
- "dockers/**"
13+
- "Makefile"
14+
- ".github/workflows/**"
15+
pull_request:
16+
paths:
17+
- "dockers/**"
18+
- "Makefile"
19+
- ".github/workflows/**"
20+
workflow_dispatch:
21+
schedule:
22+
- cron: "0 23 * * *"
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
base:
30+
uses: ./.github/workflows/docker-reusable.yaml
31+
with:
32+
image_name: base
33+
secrets: inherit
34+
35+
images:
36+
needs: base
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
image: [dart, docker, env, gcloud, go, k8s, nim, nix, rust, vald, zig]
41+
uses: ./.github/workflows/docker-reusable.yaml
42+
with:
43+
image_name: ${{ matrix.image }}
44+
secrets: inherit
45+
46+
tools:
47+
needs: [base, images]
48+
if: |
49+
always() &&
50+
needs.base.result == 'success' &&
51+
!cancelled()
52+
uses: ./.github/workflows/docker-reusable.yaml
53+
with:
54+
image_name: tools
55+
secrets: inherit
56+
57+
dev:
58+
needs: [base, images, tools]
59+
if: |
60+
always() &&
61+
needs.base.result == 'success' &&
62+
needs.tools.result == 'success' &&
63+
!cancelled()
64+
uses: ./.github/workflows/docker-reusable.yaml
65+
with:
66+
image_name: dev
67+
secrets: inherit
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "Reusable Docker Build & Merge"
2+
on:
3+
workflow_call:
4+
inputs:
5+
image_name:
6+
required: true
7+
type: string
8+
9+
jobs:
10+
build:
11+
timeout-minutes: 90
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
arch:
16+
- platform: linux/amd64
17+
runner: ubuntu-latest
18+
suffix: amd64
19+
- platform: linux/arm64/v8
20+
runner: ubuntu-24.04-arm
21+
suffix: arm64
22+
runs-on: ${{ matrix.arch.runner }}
23+
environment: copilot
24+
steps:
25+
- name: Free Disk Space (Ubuntu)
26+
if: ${{ inputs.image_name == 'go' || inputs.image_name == 'rust' || inputs.image_name == 'env' || inputs.image_name == 'nix' || inputs.image_name == 'tools' || inputs.image_name == 'vald' }}
27+
uses: endersonmenezes/free-disk-space@v3
28+
with:
29+
remove_android: true
30+
remove_dotnet: true
31+
remove_haskell: true
32+
remove_tool_cache: true
33+
remove_swap: true
34+
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
35+
remove_packages_one_command: true
36+
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
37+
rm_cmd: "rmz"
38+
39+
- uses: actions/checkout@v6
40+
with:
41+
fetch-depth: 1
42+
43+
- name: Build and Push Docker Image
44+
uses: ./.github/actions/docker
45+
with:
46+
operation: build
47+
image_name: ${{ inputs.image_name }}
48+
docker_user: ${{ secrets.DOCKERHUB_USER || 'kpango' }}
49+
docker_pass: ${{ secrets.DOCKERHUB_PASS }}
50+
github_token: ${{ secrets.GITHUB_TOKEN }}
51+
docker_push: true
52+
platform: ${{ matrix.arch.platform }}
53+
suffix: ${{ matrix.arch.suffix }}
54+
55+
merge:
56+
needs: build
57+
runs-on: ubuntu-latest
58+
environment: copilot
59+
steps:
60+
- uses: actions/checkout@v6
61+
with:
62+
fetch-depth: 1
63+
64+
- name: Merge and Push Manifest
65+
uses: ./.github/actions/docker
66+
with:
67+
operation: merge
68+
image_name: ${{ inputs.image_name }}
69+
docker_user: ${{ secrets.DOCKERHUB_USER || 'kpango' }}
70+
docker_pass: ${{ secrets.DOCKERHUB_PASS }}
71+
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)