FROM debian:trixie-slim

ENV TZ=Asia/Shanghai
ENV NODE_VERSION=23.11.1
ENV PYTHON_VERSION=3.13.12
ENV MISE_DATA_DIR=/opt/mise-base
ENV MISE_CONFIG_DIR=/opt/mise-base
ENV PATH="/opt/mise-base/shims:/opt/mise-base/bin:$PATH"

# 安装必要系统工具
RUN sed -i 's@deb.debian.org@mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources \
    && sed -i 's@security.debian.org@mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources \
    && echo "${TZ}" > /etc/timezone \
    && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
         tzdata git curl wget vim htop ca-certificates rsync openssh-client \
    && BUILD_DEPS="gcc build-essential libssl-dev zlib1g-dev libbz2-dev \
         libreadline-dev libsqlite3-dev libncursesw5-dev \
         xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev" \
    && apt-get install -y --no-install-recommends $BUILD_DEPS \
    && curl https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh \
    && MISE_DATA_DIR=/opt/mise-base MISE_CONFIG_DIR=/opt/mise-base MISE_HTTP_TIMEOUT=300 \
       PYTHON_BUILD_MIRROR_URL=https://pyenv.pages.dev/api/mirror/binaries \
       mise use -g node@${NODE_VERSION} python@${PYTHON_VERSION} \
    && mise prune -- -f \
    && apt-get purge -y --auto-remove $BUILD_DEPS \
    && ln -sf /usr/bin/python3 /usr/bin/python \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /root/.cache/mise /root/.cache/pip /opt/mise-base/cache/*
