FROM alpine:3.19

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/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
    && apk add --no-cache \
        tzdata git bash curl wget vim htop ca-certificates rsync \
    && BUILD_DEPS="build-base libffi-dev openssl-dev bzip2-dev zlib-dev readline-dev sqlite-dev ncurses-dev xz-dev" \
    && apk add --no-cache $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 \
    && apk del $BUILD_DEPS \
    && ln -sf /usr/bin/python3 /usr/bin/python \
    && cp /usr/share/zoneinfo/${TZ} /etc/localtime \
    && echo "${TZ}" > /etc/timezone \
    && rm -rf /var/cache/apk/* \
    && rm -rf /root/.cache/mise /root/.cache/pip /opt/mise-base/cache/*
