Skip to content

Commit 5f29005

Browse files
authored
Merge pull request #1 from xiaomakuaiz/main
add docker/base/bookworm/Dockerfile
2 parents a2fec41 + 116e65a commit 5f29005

File tree

4 files changed

+151
-1
lines changed

4 files changed

+151
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "docker/**"
7+
- "scripts/**"
8+
- ".github/workflows/**"
9+
- "README.md"
10+
push:
11+
branches: [main]
12+
tags: ["*"]
13+
14+
env:
15+
REGISTRY: ghcr.io/chaitin/monkeycode-runner
16+
STACK: base
17+
VERSION: bookworm
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Docker meta
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ${{ env.REGISTRY }}/${{ env.STACK }}
34+
tags: |
35+
type=raw,value=${{ env.VERSION }}
36+
type=raw,value=${{ env.VERSION }}-${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/main' }}
37+
type=ref,event=tag
38+
type=raw,value=${{ env.VERSION }}-${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
39+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
40+
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Log in to GHCR
48+
if: github.event_name == 'push'
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Build (no push on PR)
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
file: docker/${{ env.STACK }}/${{ env.VERSION }}/Dockerfile
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
# DevRunner
1+
# DevRunner
2+
3+
Base container images for Chaitin MonkeyCode developer workflows.
4+
5+
## Base image (bookworm)
6+
- Dockerfile: `docker/base/bookworm/Dockerfile` (Debian bookworm-slim, git/curl/build-essential/python3, en_US.UTF-8 locale, default user root).
7+
- Build locally: `STACK=base VERSION=bookworm ./scripts/build.sh`
8+
- Push to GHCR: `PUSH=true REGISTRY=ghcr.io/chaitin/monkeycode-runner STACK=base VERSION=bookworm ./scripts/build.sh` (needs `docker login ghcr.io`).
9+
- Run: `docker run --rm -it ghcr.io/chaitin/monkeycode-runner/base:bookworm bash`
10+
11+
## Layout
12+
- `docker/base/bookworm/Dockerfile` – base image definition.
13+
- `scripts/build.sh` – helper to build/push images (env-driven: STACK, VERSION, REGISTRY, PUSH).
14+
- `docs/` – docs placeholder for future stacks and CI notes.
15+
16+
## CI/CD
17+
- Workflow: `.github/workflows/ci.yaml`
18+
- PR: build only (no push).
19+
- Push to `main` branch: login to GHCR with `GITHUB_TOKEN` and push tags from metadata (`bookworm`, `latest`, branch/tag-derived). Non-main branches/tags build only. Target registry: `ghcr.io/chaitin/monkeycode-runner`.
20+
- No personal access token needed; workflow requests `packages: write` and `contents: read` via `GITHUB_TOKEN` (ensure Actions permissions allow this if repository is restricted).

docker/base/bookworm/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Base developer-friendly image (Debian bookworm-slim)
2+
FROM debian:bookworm-slim
3+
4+
LABEL org.opencontainers.image.title="DevRunner Base" \
5+
org.opencontainers.image.source="https://github.com/chaitin/DevRunner" \
6+
org.opencontainers.image.description="Base toolbox image for DevRunner stacks"
7+
8+
ARG DEBIAN_FRONTEND=noninteractive
9+
10+
RUN apt-get update \
11+
&& apt-get install -y --no-install-recommends \
12+
ca-certificates \
13+
locales \
14+
curl \
15+
git \
16+
gnupg \
17+
build-essential \
18+
pkg-config \
19+
unzip \
20+
zip \
21+
less \
22+
vim-tiny \
23+
procps \
24+
python3 \
25+
python3-pip \
26+
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
27+
&& locale-gen \
28+
&& update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
RUN mkdir -p /workspace
32+
33+
ENV LANG=en_US.UTF-8 \
34+
LC_ALL=en_US.UTF-8 \
35+
PATH=/root/.local/bin:${PATH} \
36+
WORKSPACE=/workspace
37+
38+
WORKDIR /workspace

scripts/build.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Simple builder for DevRunner images.
5+
# Usage:
6+
# STACK=base VERSION=bookworm REGISTRY=ghcr.io/chaitin/monkeycode-runner PUSH=false ./scripts/build.sh
7+
8+
STACK=${STACK:-base}
9+
VERSION=${VERSION:-bookworm}
10+
REGISTRY=${REGISTRY:-ghcr.io/chaitin/monkeycode-runner}
11+
PUSH=${PUSH:-false}
12+
13+
if [[ "${STACK}" == "base" ]]; then
14+
DOCKERFILE="docker/base/${VERSION}/Dockerfile"
15+
else
16+
DOCKERFILE="docker/${STACK}/${VERSION}/Dockerfile"
17+
fi
18+
19+
if [[ ! -f "${DOCKERFILE}" ]]; then
20+
echo "Dockerfile not found: ${DOCKERFILE}" >&2
21+
exit 1
22+
fi
23+
24+
IMAGE="$(echo "${REGISTRY}" | tr '[:upper:]' '[:lower:]')/${STACK}:${VERSION}"
25+
echo "Building ${IMAGE} with ${DOCKERFILE}"
26+
docker build -f "${DOCKERFILE}" -t "${IMAGE}" .
27+
28+
if [[ "${PUSH}" == "true" ]]; then
29+
echo "Pushing ${IMAGE}"
30+
docker push "${IMAGE}"
31+
fi

0 commit comments

Comments
 (0)