Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions base-images/operating-systems/anolis/23.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# These ARGs can be overridden at build time to customize the image
ARG REGISTRY=ghcr.io
ARG TOOLING_REPO=labring-actions/devbox-tooling
ARG L10N=en_US
ARG TARGETARCH
ARG ARCH=${TARGETARCH:-amd64}
ARG DEFAULT_DEVBOX_USER=devbox
ARG ANOLIS_IMAGE=openanolis/anolisos:23.4
# These ARGs are not recommended to be overridden at build time.
# Instead, update the Dockerfile directly for consistent builds,
# and release new versions as needed.
ARG BASE_TOOLS_VERSION=v0.0.1-alpha.1

FROM ${REGISTRY}/${TOOLING_REPO}/tooling:${BASE_TOOLS_VERSION} AS tooling
FROM ${ANOLIS_IMAGE}
ARG L10N
ARG TARGETARCH
ARG ARCH=${TARGETARCH:-amd64}
ARG DEFAULT_DEVBOX_USER
LABEL org.opencontainers.image.authors="The Devbox Authors"
# Define some environment variables
## BASE_TOOLS_DIR: Directory where base tools are installed
ENV BASE_TOOLS_DIR=/opt/base-tools
## L10N: Internationalization setting
ENV L10N=${L10N}
## ARCH: System architecture (from build-arg)
ENV ARCH=${ARCH}
## DEFAULT_DEVBOX_USER: Default user for the devbox environment
ENV DEFAULT_DEVBOX_USER=${DEFAULT_DEVBOX_USER}
## PROJECT_DIR: Default devbox project directory inside the container
ENV PROJECT_DIR=/home/devbox/project
## S6_STAGE2_HOOK: Hook script executed BEFORE s6-rc compilation
## This allows us to dynamically disable services based on DEVBOX_ENV
ENV S6_STAGE2_HOOK=/etc/s6-overlay-hook/pre-rc-init.d/pre-rc-init.sh
## S6_KILL_GRACETIME: Time to wait before forcefully killing all processes during shutdown
ENV S6_KILL_GRACETIME=500

# Copy tooling assets from the tooling stage
COPY --from=tooling ${BASE_TOOLS_DIR} ${BASE_TOOLS_DIR}
# Add build script and execute it
COPY build.sh /build.sh
RUN chmod +x /build.sh && \
/build.sh && \
rm -f /build.sh && \
rm -rf ${BASE_TOOLS_DIR}
## Locale: generated during build, but also export at runtime so non-login processes use UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENTRYPOINT [ "/init" ]
42 changes: 42 additions & 0 deletions base-images/operating-systems/anolis/23.4/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -euo pipefail

echo "Current BASE_TOOLS_DIR: $BASE_TOOLS_DIR"
echo "Current L10N: $L10N"
echo "Current ARCH: $ARCH"
echo "Current DEFAULT_DEVBOX_USER: $DEFAULT_DEVBOX_USER"

chmod +x "$BASE_TOOLS_DIR/scripts/"*.sh

# Install base packages for Anolis/RPM family
"$BASE_TOOLS_DIR/scripts/install-base-pkg-rpm.sh"

# Install cron, s6, and the SDK server from the shared tooling scripts
"$BASE_TOOLS_DIR/scripts/install-crond.sh"
"$BASE_TOOLS_DIR/scripts/install-s6.sh"
"$BASE_TOOLS_DIR/scripts/install-sdk-server.sh"

# Configure svc
"$BASE_TOOLS_DIR/scripts/configure-svc.sh"

# Configure other utilities
"$BASE_TOOLS_DIR/scripts/configure-logrotate.sh"
"$BASE_TOOLS_DIR/scripts/configure-login.sh"

# Configure localization (L10N)
"$BASE_TOOLS_DIR/scripts/configure-l10n.sh"

# Configure user devbox
"$BASE_TOOLS_DIR/scripts/configure-user.sh" "$DEFAULT_DEVBOX_USER"

# Install user-facing runtime docs (single source from the shared tooling bundle)
if [ -d "$BASE_TOOLS_DIR/docs" ]; then
install -d /usr/share/devbox/docs
cp "$BASE_TOOLS_DIR"/docs/README.s6-user-guide*.md /usr/share/devbox/docs/
chmod 644 /usr/share/devbox/docs/README.s6-user-guide*.md
else
echo "No docs directory found in $BASE_TOOLS_DIR; skipping s6 user-guide install"
fi

# Cleanup
"$BASE_TOOLS_DIR/scripts/cleanup.sh"
49 changes: 49 additions & 0 deletions base-images/operating-systems/kylin/v10-sp3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# These ARGs can be overridden at build time to customize the image
ARG REGISTRY=ghcr.io
ARG TOOLING_REPO=labring-actions/devbox-tooling
ARG L10N=en_US
ARG TARGETARCH
ARG ARCH=${TARGETARCH:-amd64}
ARG DEFAULT_DEVBOX_USER=devbox
ARG KYLIN_IMAGE=macrosan/kylin:v10-sp3
# These ARGs are not recommended to be overridden at build time.
# Instead, update the Dockerfile directly for consistent builds,
# and release new versions as needed.
ARG BASE_TOOLS_VERSION=v0.0.1-alpha.1

FROM ${REGISTRY}/${TOOLING_REPO}/tooling:${BASE_TOOLS_VERSION} AS tooling
FROM ${KYLIN_IMAGE}
ARG L10N
ARG TARGETARCH
ARG ARCH=${TARGETARCH:-amd64}
ARG DEFAULT_DEVBOX_USER
LABEL org.opencontainers.image.authors="The Devbox Authors"
# Define some environment variables
## BASE_TOOLS_DIR: Directory where base tools are installed
ENV BASE_TOOLS_DIR=/opt/base-tools
## L10N: Internationalization setting
ENV L10N=${L10N}
## ARCH: System architecture (from build-arg)
ENV ARCH=${ARCH}
## DEFAULT_DEVBOX_USER: Default user for the devbox environment
ENV DEFAULT_DEVBOX_USER=${DEFAULT_DEVBOX_USER}
## PROJECT_DIR: Default devbox project directory inside the container
ENV PROJECT_DIR=/home/devbox/project
## S6_STAGE2_HOOK: Hook script executed BEFORE s6-rc compilation
## This allows us to dynamically disable services based on DEVBOX_ENV
ENV S6_STAGE2_HOOK=/etc/s6-overlay-hook/pre-rc-init.d/pre-rc-init.sh
## S6_KILL_GRACETIME: Time to wait before forcefully killing all processes during shutdown
ENV S6_KILL_GRACETIME=500

# Copy tooling assets from the tooling stage
COPY --from=tooling ${BASE_TOOLS_DIR} ${BASE_TOOLS_DIR}
# Add build script and execute it
COPY build.sh /build.sh
RUN chmod +x /build.sh && \
/build.sh && \
rm -f /build.sh && \
rm -rf ${BASE_TOOLS_DIR}
## Locale: generated during build, but also export at runtime so non-login processes use UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENTRYPOINT [ "/init" ]
80 changes: 80 additions & 0 deletions base-images/operating-systems/kylin/v10-sp3/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
set -euo pipefail

echo "Current BASE_TOOLS_DIR: $BASE_TOOLS_DIR"
echo "Current L10N: $L10N"
echo "Current ARCH: $ARCH"
echo "Current DEFAULT_DEVBOX_USER: $DEFAULT_DEVBOX_USER"

chmod +x "$BASE_TOOLS_DIR/scripts/"*.sh

# Install base packages for Kylin/RPM family
"$BASE_TOOLS_DIR/scripts/install-base-pkg-rpm.sh"

# Kylin V10 SP3 ships glibc 2.28, which meets the VS Code Server Linux
# prerequisite, but its GCC 7 libstdc++ only provides GLIBCXX_3.4.24.
# Install an Anolis 8 libstdc++ build with GLIBCXX_3.4.25 while keeping the
# system glibc unchanged.
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
case "${ARCH:-amd64}" in
amd64)
rpm_arch=x86_64
libstdcxx_rpm_sha256="1cdcd031a575525b43c2787f750a855228433e982a7ddffc9d12d01f73f5ca68"
;;
arm64)
rpm_arch=aarch64
libstdcxx_rpm_sha256="412632fe27bf8ab264b8b4544a466225adc59bcb7cc30dce2f08f9630073b18c"
;;
*)
echo "Unsupported ARCH for Kylin libstdc++ compatibility package: ${ARCH:-}" >&2
exit 1
;;
esac
libstdcxx_rpm_url="https://mirrors.openanolis.cn/anolis/8/BaseOS/${rpm_arch}/os/Packages/libstdc++-8.5.0-24.0.1.an8.${rpm_arch}.rpm"
libstdcxx_rpm="$tmp_dir/libstdc++.rpm"
curl -fsSL "$libstdcxx_rpm_url" -o "$libstdcxx_rpm"
echo "$libstdcxx_rpm_sha256 $libstdcxx_rpm" | sha256sum -c -
(
cd "$tmp_dir"
rpm2cpio "$libstdcxx_rpm" | cpio -idm --quiet ./usr/lib64/libstdc++.so.6 ./usr/lib64/libstdc++.so.6.0.25
)
install -m 0755 "$tmp_dir/usr/lib64/libstdc++.so.6.0.25" /usr/lib64/libstdc++.so.6.0.25
ln -sf libstdc++.so.6.0.25 /usr/lib64/libstdc++.so.6
ldconfig
if ! grep -ao 'GLIBCXX_3\.4\.25' /usr/lib64/libstdc++.so.6 >/dev/null 2>&1; then
echo "libstdc++ does not provide GLIBCXX_3.4.25" >&2
exit 1
fi
rm -rf "$tmp_dir"
trap - EXIT

# Install cron, s6, and the SDK server from the shared tooling scripts
"$BASE_TOOLS_DIR/scripts/install-crond.sh"
"$BASE_TOOLS_DIR/scripts/install-s6.sh"
"$BASE_TOOLS_DIR/scripts/install-sdk-server.sh"

# Configure svc
"$BASE_TOOLS_DIR/scripts/configure-svc.sh"

# Configure other utilities
"$BASE_TOOLS_DIR/scripts/configure-logrotate.sh"
"$BASE_TOOLS_DIR/scripts/configure-login.sh"

# Configure localization (L10N)
"$BASE_TOOLS_DIR/scripts/configure-l10n.sh"

# Configure user devbox
"$BASE_TOOLS_DIR/scripts/configure-user.sh" "$DEFAULT_DEVBOX_USER"

# Install user-facing runtime docs (single source from the shared tooling bundle)
if [ -d "$BASE_TOOLS_DIR/docs" ]; then
install -d /usr/share/devbox/docs
cp "$BASE_TOOLS_DIR"/docs/README.s6-user-guide*.md /usr/share/devbox/docs/
chmod 644 /usr/share/devbox/docs/README.s6-user-guide*.md
else
echo "No docs directory found in $BASE_TOOLS_DIR; skipping s6 user-guide install"
fi

# Cleanup
"$BASE_TOOLS_DIR/scripts/cleanup.sh"
25 changes: 25 additions & 0 deletions runtime-images/operating-systems/anolis/23.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# These ARGs can be overridden at build time to customize the image
ARG REPO=labring-actions/devbox-base-images
ARG REGISTRY=ghcr.io
ARG L10N=en_US
ARG L10N_NORMALIZED=en-us
ARG DEFAULT_DEVBOX_USER=devbox

# These ARGs are not recommended to be overridden at build time.
# Instead, update the Dockerfile directly for consistent builds,
# and release new versions as needed.
ARG OS_IMAGE_VERSION=v0.0.1-alpha.1-${L10N_NORMALIZED}

FROM ${REGISTRY}/${REPO}/anolis-23.4:${OS_IMAGE_VERSION}
ARG L10N
ARG DEFAULT_DEVBOX_USER
ENV L10N=${L10N}
ENV PROJECT_TEMPLATE_DIR=/project-template
COPY ./project-template ${PROJECT_TEMPLATE_DIR}
COPY ./build.sh /build.sh
RUN chmod +x /build.sh && \
/build.sh && \
rm -f /build.sh && \
rm -rf ${PROJECT_TEMPLATE_DIR}
# Set the working directory to the default devbox user's project directory
WORKDIR /home/${DEFAULT_DEVBOX_USER}/project
33 changes: 33 additions & 0 deletions runtime-images/operating-systems/anolis/23.4/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail

L10N=${L10N:-en_US}
DEFAULT_DEVBOX_USER=${DEFAULT_DEVBOX_USER:-devbox}
PROJECT_TEMPLATE_DIR=${PROJECT_TEMPLATE_DIR:-/project-templates}
DOCS_DIR=${DOCS_DIR:-/usr/share/devbox/docs}

if ! id -u "$DEFAULT_DEVBOX_USER" &>/dev/null; then
echo "User $DEFAULT_DEVBOX_USER does not exist"
exit 1
fi

TARGET_DIR="/home/$DEFAULT_DEVBOX_USER/project"
mkdir -p "$TARGET_DIR"

if [ -f "$PROJECT_TEMPLATE_DIR/README.$L10N.md" ]; then
echo "README $PROJECT_TEMPLATE_DIR/README.$L10N.md exists. Copying to $TARGET_DIR/README.md"
cp "$PROJECT_TEMPLATE_DIR/README.$L10N.md" "$TARGET_DIR/README.md"
else
echo "README $PROJECT_TEMPLATE_DIR/README.$L10N.md does not exist. Skipping copy."
fi

if [ -f "$DOCS_DIR/README.s6-user-guide.$L10N.md" ]; then
cp "$DOCS_DIR/README.s6-user-guide.$L10N.md" "$TARGET_DIR/README.s6-user-guide.md"
elif [ -f "$DOCS_DIR/README.s6-user-guide.en_US.md" ]; then
cp "$DOCS_DIR/README.s6-user-guide.en_US.md" "$TARGET_DIR/README.s6-user-guide.md"
fi

cp "$PROJECT_TEMPLATE_DIR/"*.sh "$TARGET_DIR/"

# Set ownership to default devbox user
chown -R "$DEFAULT_DEVBOX_USER:$DEFAULT_DEVBOX_USER" "$TARGET_DIR"
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# AnolisOS 23.4 Runtime Template

This template provides a minimal **operating-system runtime** based on Anolis OS 23.4.
Use it when you need a localized Linux base and full control of your language, framework, or application stack.

## Runtime Summary

- OS version: `Anolis OS 23.4`
- Base runtime image: `anolis-23.4`
- Entrypoint script: `entrypoint.sh`
- Default service port: `8080`

## Template Files

- `entrypoint.sh`: creates a static `index.html` and starts a lightweight HTTP server

## Run in DevBox

Run commands from `/home/devbox/project`.

```bash
bash entrypoint.sh
```

Behavior:
- Uses `PORT` environment variable when provided, defaults to `8080`.
- Serves files from `/home/devbox/project/www`.
- Prefers `busybox httpd` and falls back to `python3 -m http.server` when that applet is unavailable.

## Verify Service

```bash
curl http://127.0.0.1:8080
```

Expected output:

```text
Hello, World!
```

## Customization

- Replace `entrypoint.sh` with your own process startup script.
- Use `dnf` or `yum` to install application dependencies in this AnolisOS base.
- Align container exposed ports with your service port.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# AnolisOS 23.4 运行时模板

该模板提供一个基于 Anolis OS 23.4 的最小化**操作系统运行时**。
适用于需要国产化 Linux 基础环境,并在其上自行安装语言、框架或业务依赖的场景。

## 运行时概览

- 系统版本:`Anolis OS 23.4`
- 基础运行时镜像:`anolis-23.4`
- 启动脚本:`entrypoint.sh`
- 默认服务端口:`8080`

## 模板文件

- `entrypoint.sh`:生成静态 `index.html` 并启动轻量 HTTP 服务

## 在 DevBox 中运行

以下命令在 `/home/devbox/project` 目录执行。

```bash
bash entrypoint.sh
```

行为说明:
- 支持通过 `PORT` 环境变量覆盖端口,默认值为 `8080`。
- 默认从 `/home/devbox/project/www` 目录提供静态内容。
- 优先使用 `busybox httpd`,不可用时回退到 `python3 -m http.server`。

## 验证服务

```bash
curl http://127.0.0.1:8080
```

预期输出:

```text
Hello, World!
```

## 自定义建议

- 可将 `entrypoint.sh` 替换为你的进程启动脚本。
- 使用 `dnf` 或 `yum` 在该 AnolisOS 基础镜像中安装业务依赖。
- 保持容器暴露端口与服务监听端口一致。
Loading