feat: builds support amd64+arm64

This commit is contained in:
Sun-ZhenXing
2026-01-01 22:38:08 +08:00
parent 922068b8af
commit ab07facdb1
10 changed files with 97 additions and 27 deletions

View File

@@ -1,5 +1,12 @@
# Debian DinD Configuration
# Global registry prefix (optional, e.g., docker.io/, ghcr.io/)
# GLOBAL_REGISTRY=
# Image versions
DEBIAN_DIND_VERSION=0.1.1
DEBIAN_DIND_GPU_VERSION=0.1.1-gpu
# Timezone (default: UTC)
TZ=UTC

View File

@@ -37,13 +37,19 @@ A Docker-in-Docker (DinD) service based on Debian, allowing you to run Docker in
Key environment variables (see `.env.example` for all options):
| Variable | Description | Default |
| ------------------------ | ----------------------------------- | ----------- |
| ------------------------- | ----------------------------------- | -------------------- |
| `GLOBAL_REGISTRY` | Global registry prefix (optional) | - |
| `DEBIAN_DIND_VERSION` | Main DinD image version | `0.1.1` |
| `DEBIAN_DIND_GPU_VERSION` | GPU-enabled DinD image version | `0.1.1-gpu` |
| `DEBIAN_VERSION` | Debian base image version | `13.2-slim` |
| `DIND_PORT_OVERRIDE` | Host port for Docker daemon | `2375` |
| `INSTALL_NVIDIA_TOOLKIT` | Install NVIDIA toolkit during build | `false` |
| `TZ` | Timezone | `UTC` |
| `DIND_CPU_LIMIT` | CPU limit | `2.0` |
| `DIND_MEMORY_LIMIT` | Memory limit | `4G` |
| `DIND_CPU_RESERVATION` | CPU reservation | `1.0` |
| `DIND_MEMORY_RESERVATION` | Memory reservation | `2G` |
| `DOCKER_TLS_CERTDIR` | TLS certificate directory | Empty (TLS disabled) |
## GPU Support

View File

@@ -37,13 +37,19 @@
主要环境变量(查看 `.env.example` 了解所有选项):
| 变量 | 说明 | 默认值 |
| ------------------------ | ------------------------- | ----------- |
| ------------------------- | ------------------------- | ---------------- |
| `GLOBAL_REGISTRY` | 全局镜像仓库前缀(可选) | - |
| `DEBIAN_DIND_VERSION` | 主 DinD 镜像版本 | `0.1.1` |
| `DEBIAN_DIND_GPU_VERSION` | GPU 版本 DinD 镜像版本 | `0.1.1-gpu` |
| `DEBIAN_VERSION` | Debian 基础镜像版本 | `13.2-slim` |
| `DIND_PORT_OVERRIDE` | Docker 守护进程的主机端口 | `2375` |
| `INSTALL_NVIDIA_TOOLKIT` | 构建时安装 NVIDIA 工具包 | `false` |
| `TZ` | 时区 | `UTC` |
| `DIND_CPU_LIMIT` | CPU 限制 | `2.0` |
| `DIND_MEMORY_LIMIT` | 内存限制 | `4G` |
| `DIND_CPU_RESERVATION` | CPU 预留 | `1.0` |
| `DIND_MEMORY_RESERVATION` | 内存预留 | `2G` |
| `DOCKER_TLS_CERTDIR` | TLS 证书目录 | 空TLS 已禁用) |
## GPU 支持

View File

@@ -12,12 +12,15 @@ x-defaults: &defaults
services:
dind:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}alexsuntop/debian-dind:${DEBIAN_DIND_VERSION:-0.1.0}
image: ${GLOBAL_REGISTRY:-}alexsuntop/debian-dind:${DEBIAN_DIND_VERSION:-0.1.1}
profiles:
- ${COMPOSE_PROFILES:-}
build:
context: .
dockerfile: Dockerfile
platforms:
- linux/amd64
- linux/arm64
args:
- DEBIAN_VERSION=${DEBIAN_VERSION:-13.2-slim}
- INSTALL_NVIDIA_TOOLKIT=${INSTALL_NVIDIA_TOOLKIT:-false}
@@ -47,12 +50,15 @@ services:
# GPU-enabled DinD (optional)
dind-gpu:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}alexsuntop/debian-dind:${DEBIAN_DIND_GPU_VERSION:-0.1.0-gpu}
image: ${GLOBAL_REGISTRY:-}alexsuntop/debian-dind:${DEBIAN_DIND_GPU_VERSION:-0.1.1-gpu}
profiles:
- gpu
build:
context: .
dockerfile: Dockerfile
platforms:
- linux/amd64
- linux/arm64
args:
- DEBIAN_VERSION=${DEBIAN_VERSION:-13.2-slim}
- INSTALL_NVIDIA_TOOLKIT=true

View File

@@ -7,7 +7,13 @@ K3S_VERSION=v1.28.2+k3s1
# K3s DinD Image Version
# Built image version tag
K3S_DIND_VERSION=0.2.1
K3S_DIND_VERSION=0.2.2
# Multi-platform Build Support
# This image supports building for multiple platforms: linux/amd64, linux/arm64
# Build for current platform: docker compose build
# Build multi-platform: docker buildx build --platform linux/amd64,linux/arm64 -t IMAGE_NAME --push .
# Preload Images
# Whether to pre-download common images during build (true/false)
# Set to false to speed up build time if you have good internet connectivity

View File

@@ -1,6 +1,6 @@
FROM docker:29-dind
ARG TARGETARCH=amd64
ARG TARGETARCH
ARG K3S_VERSION=v1.28.2+k3s1
ARG PRELOAD_IMAGES="true"

View File

@@ -9,7 +9,7 @@ A lightweight Kubernetes distribution (K3s) running inside a Docker-in-Docker (D
- ✅ Complete K3s cluster in a single container
- ✅ Docker-in-Docker support for containerized workloads
- ✅ Kubernetes API server exposed on port 6443
- ✅ Multi-architecture support (x86-64, ARM64)
- ✅ Multi-platform support (linux/amd64, linux/arm64)
- ✅ Resource limits to prevent system exhaustion
- ✅ Health checks for cluster readiness
- ✅ Persistent storage for K3s and Docker data
@@ -62,7 +62,7 @@ A lightweight Kubernetes distribution (K3s) running inside a Docker-in-Docker (D
| Variable | Default | Description |
| ----------------------------- | -------------- | ------------------------------------- |
| `K3S_VERSION` | `v1.28.2+k3s1` | K3s version to install |
| `K3S_DIND_VERSION` | `0.2.1` | Built image version tag |
| `K3S_DIND_VERSION` | `0.2.2` | Built image version tag |
| `PRELOAD_IMAGES` | `true` | Pre-download images during build |
| `TZ` | `UTC` | Container timezone |
| `K3S_API_PORT_OVERRIDE` | `6443` | Kubernetes API server port |
@@ -166,6 +166,24 @@ Ensure the kubeconfig server address points to `localhost` or the correct IP:
kubectl cluster-info
```
## Building Multi-Platform Images
This image supports `linux/amd64` and `linux/arm64` platforms automatically.
```bash
# Build for current platform
docker compose build
# Build and push multi-platform image (requires Docker Buildx)
docker buildx build --platform linux/amd64,linux/arm64 \
-t alexsuntop/k3s-inside-dind:0.2.2 --push .
# Customize K3s version
docker buildx build --platform linux/amd64,linux/arm64 \
--build-arg K3S_VERSION=v1.29.0+k3s1 \
-t myregistry/k3s-dind:1.0.0 --push .
```
## Advanced Configuration
### Customize K3s Server Arguments

View File

@@ -9,7 +9,7 @@
- ✅ 在单个容器中运行完整的 K3s 集群
- ✅ 支持 Docker-in-Docker可运行容器化工作负载
- ✅ 在 6443 端口暴露 Kubernetes API 服务器
- ✅ 支持多架构x86-64、ARM64
- ✅ 支持多平台linux/amd64、linux/arm64
- ✅ 资源限制防止系统资源耗尽
- ✅ 健康检查确保集群就绪
- ✅ 持久化存储 K3s 和 Docker 数据
@@ -62,7 +62,7 @@
| 变量 | 默认值 | 说明 |
| ----------------------------- | -------------- | ------------------------- |
| `K3S_VERSION` | `v1.28.2+k3s1` | 要安装的 K3s 版本 |
| `K3S_DIND_VERSION` | `0.2.1` | 构建的镜像版本标签 |
| `K3S_DIND_VERSION` | `0.2.2` | 构建的镜像版本标签 |
| `PRELOAD_IMAGES` | `true` | 构建时预下载镜像 |
| `TZ` | `UTC` | 容器时区 |
| `K3S_API_PORT_OVERRIDE` | `6443` | Kubernetes API 服务器端口 |
@@ -166,6 +166,24 @@ docker compose logs -f k3s
kubectl cluster-info
```
## 构建多平台镜像
此镜像自动支持 `linux/amd64` 和 `linux/arm64` 平台。
```bash
# 构建当前平台
docker compose build
# 构建并推送多平台镜像(需要 Docker Buildx
docker buildx build --platform linux/amd64,linux/arm64 \
-t alexsuntop/k3s-inside-dind:0.2.2 --push .
# 自定义 K3s 版本
docker buildx build --platform linux/amd64,linux/arm64 \
--build-arg K3S_VERSION=v1.29.0+k3s1 \
-t myregistry/k3s-dind:1.0.0 --push .
```
## 高级配置
### 自定义 K3s 服务器参数

View File

@@ -13,10 +13,13 @@ x-defaults: &defaults
services:
k3s:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}alexsuntop/k3s-inside-dind:${K3S_DIND_VERSION:-0.2.1}
image: ${GLOBAL_REGISTRY:-}alexsuntop/k3s-inside-dind:${K3S_DIND_VERSION:-0.2.2}
build:
context: .
dockerfile: Dockerfile
platforms:
- linux/amd64
- linux/arm64
args:
K3S_VERSION: ${K3S_VERSION:-v1.28.2+k3s1}
PRELOAD_IMAGES: ${PRELOAD_IMAGES:-true}

View File

@@ -28,11 +28,11 @@ services:
- pingap
- --autoreload
healthcheck:
test: ["CMD-SHELL", "echo > /dev/tcp/localhost/80"]
test: ["CMD-SHELL", "bash -c 'echo > /dev/tcp/localhost/80'"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
start_period: 5s
deploy:
resources:
limits: