|
1 | | -# Base |
| 1 | +# DevContainers |
2 | 2 |
|
3 | | - |
4 | | - |
5 | | - |
6 | | - |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
7 | 7 |
|
8 | | -Docker base template providing standardized container foundations with flexible entrypoint systems, multi-architecture support, and consistent configuration patterns across Alpine, Debian, and Rocky Linux distributions. |
| 8 | +Docker Image packaging for DevContainers. (amd64, arm64) |
9 | 9 |
|
10 | | -## Overview |
| 10 | +# Usage |
11 | 11 |
|
12 | | -The Docker base template serves as a foundational starting point for building containerized applications. It provides: |
| 12 | +To help you get started creating a container from this image you can either use docker-compose or the docker cli. |
13 | 13 |
|
14 | | -- **Standardized Dockerfiles** with OCI annotations and best practices |
15 | | -- **Flexible entrypoint system** supporting custom initialization scripts |
16 | | -- **Consistent environment variable configuration** across all variants |
17 | | -- **Multi-architecture support** for diverse hardware platforms |
18 | | -- **User/group management** with PUID/PGID support for permission handling |
19 | | -- **Three distribution variants**: Alpine (lightweight), Debian (default/widely-compatible), Rocky (enterprise) |
| 14 | +## Docker Cli |
20 | 15 |
|
21 | | -## Quick Start |
22 | | - |
23 | | -```bash |
24 | | -# Pull and run the default Debian variant |
25 | | -docker pull snowdreamtech/base:debian |
26 | | -docker run -d --name=base -e TZ=Asia/Shanghai snowdreamtech/base:debian |
27 | | - |
28 | | -# Or use docker-compose |
29 | | -docker-compose up -d |
30 | | -``` |
31 | | - |
32 | | -## Distribution Variants |
33 | | - |
34 | | -### Debian (Default) |
35 | | - |
36 | | -The recommended variant for most use cases, providing wide compatibility and extensive package availability. |
37 | | - |
38 | | -```bash |
39 | | -docker run -d \ |
40 | | - --name=base \ |
41 | | - -e TZ=Asia/Shanghai \ |
42 | | - --restart unless-stopped \ |
43 | | - snowdreamtech/base:debian |
44 | | -``` |
45 | | - |
46 | | -**Supported Architectures**: i386, amd64, arm32v5, arm32v7, arm64, mips64le, ppc64le, s390x |
47 | | - |
48 | | -**Base Image**: `snowdreamtech/debian:13.5.0` |
49 | | - |
50 | | -### Alpine |
51 | | - |
52 | | -Lightweight variant optimized for minimal image size and fast startup times. |
| 16 | +### Simple |
53 | 17 |
|
54 | 18 | ```bash |
55 | 19 | docker run -d \ |
56 | | - --name=base \ |
| 20 | + --name=devcontainers \ |
57 | 21 | -e TZ=Asia/Shanghai \ |
58 | 22 | --restart unless-stopped \ |
59 | | - snowdreamtech/base:alpine |
| 23 | + snowdreamtech/devcontainers:latest |
60 | 24 | ``` |
61 | 25 |
|
62 | | -**Supported Architectures**: i386, amd64, arm32v6, arm32v7, arm64, ppc64le, riscv64, s390x |
63 | | - |
64 | | -**Base Image**: `snowdreamtech/alpine:3.24.0` |
65 | | - |
66 | | -### Rocky |
67 | | - |
68 | | -Enterprise-focused variant based on Rocky Linux, ideal for production environments requiring RHEL compatibility. |
| 26 | +### Advance |
69 | 27 |
|
70 | 28 | ```bash |
71 | 29 | docker run -d \ |
72 | | - --name=base \ |
| 30 | + --name=devcontainers \ |
73 | 31 | -e TZ=Asia/Shanghai \ |
| 32 | + -v /path/to/data:/path/to/data \ |
74 | 33 | --restart unless-stopped \ |
75 | | - snowdreamtech/base:rocky |
76 | | -``` |
77 | | - |
78 | | -**Supported Architectures**: i386, amd64, arm32v5, arm32v7, arm64, mips64le, ppc64le, s390x |
79 | | - |
80 | | -**Base Image**: `snowdreamtech/rocky:10.2.0` |
81 | | - |
82 | | -## Build Instructions |
83 | | - |
84 | | -### Single Architecture Build |
85 | | - |
86 | | -```bash |
87 | | -# Build Debian variant |
88 | | -docker build -t snowdreamtech/base:debian ./docker/debian/ |
89 | | - |
90 | | -# Build Alpine variant |
91 | | -docker build -t snowdreamtech/base:alpine ./docker/alpine/ |
92 | | - |
93 | | -# Build Rocky variant |
94 | | -docker build -t snowdreamtech/base:rocky ./docker/rocky/ |
95 | | -``` |
96 | | - |
97 | | -### Multi-Architecture Build |
98 | | - |
99 | | -Build images for multiple architectures using `docker buildx`: |
100 | | - |
101 | | -```bash |
102 | | -# Create and use a buildx builder |
103 | | -docker buildx create --use --name build --node build --driver-opt network=host |
104 | | - |
105 | | -# Build Debian for multiple architectures |
106 | | -docker buildx build \ |
107 | | - --platform=linux/386,linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64,linux/mips64le,linux/ppc64le,linux/s390x \ |
108 | | - -t snowdreamtech/base:debian \ |
109 | | - ./docker/debian/ \ |
110 | | - --push |
111 | | - |
112 | | -# Build Alpine for multiple architectures |
113 | | -docker buildx build \ |
114 | | - --platform=linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x \ |
115 | | - -t snowdreamtech/base:alpine \ |
116 | | - ./docker/alpine/ \ |
117 | | - --push |
118 | | - |
119 | | -# Build Rocky for multiple architectures |
120 | | -docker buildx build \ |
121 | | - --platform=linux/386,linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64,linux/mips64le,linux/ppc64le,linux/s390x \ |
122 | | - -t snowdreamtech/base:rocky \ |
123 | | - ./docker/rocky/ \ |
124 | | - --push |
| 34 | + snowdreamtech/devcontainers:latest |
125 | 35 | ``` |
126 | 36 |
|
127 | | -## Environment Variables |
128 | | - |
129 | | -All variants support the following environment variables for runtime configuration: |
130 | | - |
131 | | -| Variable | Default | Description | |
132 | | -|----------|---------|-------------| |
133 | | -| `KEEPALIVE` | `0` | Keep container running (1=enabled, 0=disabled) | |
134 | | -| `CAP_NET_BIND_SERVICE` | `0` | Enable binding to privileged ports (<1024) | |
135 | | -| `LANG` | `C.UTF-8` | Locale setting for UTF-8 character support | |
136 | | -| `UMASK` | `022` | Default file creation mask | |
137 | | -| `DEBUG` | `false` | Enable debug output in entrypoint scripts | |
138 | | -| `PGID` | `0` | Primary group ID for custom user creation | |
139 | | -| `PUID` | `0` | User ID for custom user creation | |
140 | | -| `USER` | `root` | Username for custom user creation | |
141 | | -| `WORKDIR` | `/root` | Working directory path | |
142 | | -| `TZ` | - | Timezone (e.g., `Asia/Shanghai`, `America/New_York`) | |
143 | | - |
144 | | -**Debian-specific**: |
145 | | - |
146 | | -| Variable | Default | Description | |
147 | | -|----------|---------|-------------| |
148 | | -| `DEBIAN_FRONTEND` | `noninteractive` | Debian package installation mode | |
| 37 | +## Docker Compose |
149 | 38 |
|
150 | | -### Custom User Creation |
151 | | - |
152 | | -Create a non-root user with specific UID/GID at build time: |
153 | | - |
154 | | -```bash |
155 | | -docker build \ |
156 | | - --build-arg PUID=1000 \ |
157 | | - --build-arg PGID=1000 \ |
158 | | - --build-arg USER=appuser \ |
159 | | - -t snowdreamtech/base:debian-custom \ |
160 | | - ./docker/debian/ |
161 | | -``` |
162 | | - |
163 | | -Or at runtime (requires rebuilding the image): |
| 39 | +### Simple |
164 | 40 |
|
165 | 41 | ```bash |
166 | | -docker run -d \ |
167 | | - --name=base \ |
168 | | - -e PUID=1000 \ |
169 | | - -e PGID=1000 \ |
170 | | - -e USER=appuser \ |
171 | | - snowdreamtech/base:debian |
172 | | -``` |
173 | | - |
174 | | -**Note**: User creation only occurs when `PUID≠0`, `PGID≠0`, and `USER≠root`. |
175 | | - |
176 | | -## Docker Compose Examples |
177 | | - |
178 | | -### Simple Configuration |
179 | | - |
180 | | -```yaml |
181 | 42 | services: |
182 | 43 | base: |
183 | | - image: snowdreamtech/base:debian |
184 | | - container_name: base |
| 44 | + image: snowdreamtech/devcontainers:latest |
| 45 | + container_name: devcontainers |
185 | 46 | environment: |
186 | 47 | - TZ=Asia/Shanghai |
187 | 48 | restart: unless-stopped |
188 | 49 | ``` |
189 | 50 |
|
190 | | -### Advanced Configuration |
| 51 | +### Advance |
191 | 52 |
|
192 | | -```yaml |
| 53 | +```bash |
193 | 54 | services: |
194 | 55 | base: |
195 | | - image: snowdreamtech/base:debian |
196 | | - container_name: base |
| 56 | + image: snowdreamtech/devcontainers:latest |
| 57 | + container_name: devcontainers |
197 | 58 | environment: |
198 | 59 | - TZ=Asia/Shanghai |
199 | | - - DEBUG=true |
200 | | - - KEEPALIVE=1 |
201 | 60 | volumes: |
202 | | - - /path/to/data:/data |
| 61 | + - /path/to/data:/path/to/data |
203 | 62 | restart: unless-stopped |
204 | 63 | ``` |
205 | 64 |
|
206 | | -## Semantic Versioning Tags |
207 | | -
|
208 | | -Images follow semantic versioning with the format: `{major}-v{major}.{minor}.{patch}` |
209 | | - |
210 | | -Examples: |
211 | | - |
212 | | -- `snowdreamtech/base:debian-13-v13.5.0` |
213 | | -- `snowdreamtech/base:alpine-3-v3.24.0` |
214 | | -- `snowdreamtech/base:rocky-10-v10.2.0` |
215 | | - |
216 | | -This format allows: |
217 | | - |
218 | | -- **Major version pinning**: `debian-13` (tracks latest 13.x.x) |
219 | | -- **Full version pinning**: `debian-13-v13.5.0` (exact version) |
220 | | -- **Latest tag**: `debian` or `latest` (tracks most recent release) |
221 | | - |
222 | | -## Architecture Support |
223 | | - |
224 | | -Each distribution variant supports multiple CPU architectures for deployment across diverse hardware platforms: |
225 | | - |
226 | | -| Variant | Architectures | |
227 | | -|---------|---------------| |
228 | | -| **Debian** | i386, amd64, arm32v5, arm32v7, arm64, mips64le, ppc64le, s390x | |
229 | | -| **Alpine** | i386, amd64, arm32v6, arm32v7, arm64, ppc64le, riscv64, s390x | |
230 | | -| **Rocky** | i386, amd64, arm32v5, arm32v7, arm64, mips64le, ppc64le, s390x | |
231 | | - |
232 | | -Docker automatically selects the appropriate architecture for your platform when pulling images. |
233 | | - |
234 | | -## Entrypoint System |
235 | | - |
236 | | -The base template includes a flexible entrypoint system that executes custom initialization scripts before starting your application. |
237 | | - |
238 | | -### How It Works |
239 | | - |
240 | | -1. The `docker-entrypoint.sh` script runs at container startup |
241 | | -2. It executes all executable scripts in `/usr/local/bin/entrypoint.d/` in lexical order |
242 | | -3. Each script receives the container's command-line arguments |
243 | | -4. If any script fails, the container stops (fail-fast behavior) |
244 | | - |
245 | | -### Adding Custom Initialization |
246 | | - |
247 | | -Create custom initialization scripts in your derived Dockerfile: |
248 | | - |
249 | | -```dockerfile |
250 | | -FROM snowdreamtech/base:debian |
251 | | -
|
252 | | -# Add your custom initialization script |
253 | | -COPY my-init.sh /usr/local/bin/entrypoint.d/20-my-init.sh |
254 | | -RUN chmod +x /usr/local/bin/entrypoint.d/20-my-init.sh |
255 | | -
|
256 | | -# Your application setup |
257 | | -COPY app /app |
258 | | -CMD ["/app/start.sh"] |
259 | | -``` |
260 | | - |
261 | | -### Debug Mode |
262 | | - |
263 | | -Enable debug output to troubleshoot entrypoint execution: |
264 | | - |
265 | | -```bash |
266 | | -docker run -e DEBUG=true snowdreamtech/base:debian |
267 | | -``` |
268 | | - |
269 | | -Output example: |
270 | | - |
271 | | -``` |
272 | | -→ [ENTRYPOINT] Executing all scripts in /usr/local/bin/entrypoint.d |
273 | | -→ Running /usr/local/bin/entrypoint.d/10-base-init.sh |
274 | | -→ [ENTRYPOINT] Done. |
275 | | -``` |
276 | | - |
277 | | -## Development |
278 | | - |
279 | | -### Prerequisites |
280 | | - |
281 | | -- Docker (>= 20.10) |
282 | | -- Docker Buildx plugin |
283 | | - |
284 | | -### Building Locally |
285 | | - |
286 | | -```bash |
287 | | -# Build all variants |
288 | | -make build |
289 | | -
|
290 | | -# Build specific variant |
291 | | -docker build -t base:debian ./docker/debian/ |
292 | | -docker build -t base:alpine ./docker/alpine/ |
293 | | -docker build -t base:rocky ./docker/rocky/ |
294 | | -``` |
295 | | - |
296 | | -### Testing |
| 65 | +# Development |
297 | 66 |
|
298 | 67 | ```bash |
299 | | -# Test default configuration |
300 | | -docker run --rm base:debian id |
301 | | -
|
302 | | -# Test custom user creation |
303 | | -docker build --build-arg PUID=1000 --build-arg PGID=1000 --build-arg USER=testuser -t base:debian-test ./docker/debian/ |
304 | | -docker run --rm base:debian-test id |
305 | | -# Expected: uid=1000(testuser) gid=1000(testuser) |
306 | | -
|
307 | | -# Test DEBUG mode |
308 | | -docker run --rm -e DEBUG=true base:debian |
| 68 | +docker buildx create --use --name build --node build --driver-opt network=host |
| 69 | +docker buildx build -t snowdreamtech/devcontainers --platform=linux/amd64,linux/arm64 . --push |
309 | 70 | ``` |
310 | 71 |
|
311 | 72 | ## Reference |
312 | 73 |
|
313 | 74 | 1. [使用 buildx 构建多平台 Docker 镜像](https://icloudnative.io/posts/multiarch-docker-with-buildx/) |
314 | | -2. [如何使用 docker buildx 构建跨平台 Go 镜像](https://waynerv.com/posts/building-multi-architecture-images-with-docker-buildx/#buildx-%E7%9A%84%E8%B7%A8%E5%B9%B3%E5%8F%B0%E6%9E%84%E5%BB%BA%E7%AD%96%E7%95%A5) |
315 | | -3. [Building Multi-Arch Images for Arm and x86 with Docker Desktop](https://www.docker.com/blog/multi-arch-images/) |
316 | | -4. [How to Rapidly Build Multi-Architecture Images with Buildx](https://www.docker.com/blog/how-to-rapidly-build-multi-architecture-images-with-buildx/) |
317 | | -5. [Faster Multi-Platform Builds: Dockerfile Cross-Compilation Guide](https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/) |
318 | | -6. [docker/buildx](https://github.com/docker/buildx) |
319 | | - |
320 | | -## Contact (备注:base) |
321 | | - |
322 | | -* Email: <sn0wdr1am@qq.com> |
323 | | -* QQ: 3217680847 |
324 | | -* QQ群: 949022145 |
325 | | -* WeChat/微信群: sn0wdr1am |
| 75 | +1. [如何使用 docker buildx 构建跨平台 Go 镜像](https://waynerv.com/posts/building-multi-architecture-images-with-docker-buildx/#buildx-%E7%9A%84%E8%B7%A8%E5%B9%B3%E5%8F%B0%E6%9E%84%E5%BB%BA%E7%AD%96%E7%95%A5) |
| 76 | +1. [Building Multi-Arch Images for Arm and x86 with Docker Desktop](https://www.docker.com/blog/multi-arch-images/) |
| 77 | +1. [How to Rapidly Build Multi-Architecture Images with Buildx](https://www.docker.com/blog/how-to-rapidly-build-multi-architecture-images-with-buildx/) |
| 78 | +1. [Faster Multi-Platform Builds: Dockerfile Cross-Compilation Guide](https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/) |
| 79 | +1. [docker/buildx](https://github.com/docker/buildx) |
| 80 | + |
| 81 | +## Contact (备注:devcontainers) |
| 82 | + |
| 83 | +- Email: sn0wdr1am@qq.com |
| 84 | +- QQ: 3217680847 |
| 85 | +- QQ群: 949022145 |
| 86 | +- WeChat/微信群: sn0wdr1am |
326 | 87 |
|
327 | 88 | ## License |
328 | 89 |
|
|
0 commit comments