content: FROM python:3.10.11-alpine
  RUN apk add --no-cache --virtual .build-deps \
          libffi-dev \
          gcc \
          musl-dev \
          libxml2-dev \
          libxslt-dev \
      && apk add --no-cache $(echo $(wget --no-check-certificate -qO- https://raw.githubusercontent.com/demigody/nas-tools/beta/package_list.txt)) \
      && curl https://rclone.org/install.sh | bash \
      && if [ "$(uname -m)" = "x86_64" ]; then ARCH=amd64; elif [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi \
      && curl https://dl.min.io/client/mc/release/linux-${ARCH}/mc --create-dirs -o /usr/bin/mc \
      && chmod +x /usr/bin/mc \
      && pip install --upgrade pip setuptools wheel \
      && pip install cython \
      && pip install -r https://raw.githubusercontent.com/demigody/nas-tools/beta/requirements.txt \
      && apk del --purge .build-deps \
      && rm -rf /tmp/* /root/.cache /var/cache/apk/*
  ENV S6_SERVICES_GRACETIME=30000 \
      S6_KILL_GRACETIME=60000 \
      S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
      S6_SYNC_DISKS=1 \
      HOME="/nt" \
      TERM="xterm" \
      PATH=${PATH}:/usr/lib/chromium \
      LANG="C.UTF-8" \
      TZ="Asia/Shanghai" \
      NASTOOL_CONFIG="/config/config.yaml" \
      NASTOOL_AUTO_UPDATE=false \
      NASTOOL_CN_UPDATE=true \
      NASTOOL_VERSION=beta \
      PS1="\u@\h:\w \$ " \
      REPO_URL="https://github.com/demigody/nas-tools.git" \
      PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
      ALPINE_MIRROR="mirrors.ustc.edu.cn" \
      PUID=0 \
      PGID=0 \
      UMASK=000 \
      PYTHONWARNINGS="ignore:semaphore_tracker:UserWarning" \
      WORKDIR="/nas-tools"
  WORKDIR ${WORKDIR}
  RUN mkdir ${HOME} \
      && addgroup -S nt -g 911 \
      && adduser -S nt -G nt -h ${HOME} -s /bin/bash -u 911 \
      && python_ver=$(python3 -V | awk '{print $2}') \
      && python_path=$(which python3) \
      && [ -d "/usr/lib/python${python_ver%.*}/site-packages" ] || mkdir -p "/usr/lib/python${python_ver%.*}/site-packages" \
      && echo "${WORKDIR}/" > /usr/lib/python${python_ver%.*}/site-packages/nas-tools.pth \
      && echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
      && echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
      && echo "nt ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
      && git config --global pull.ff only \
      && git clone -b beta ${REPO_URL} ${WORKDIR} --depth=1 --recurse-submodule \
      && git config --global --add safe.directory ${WORKDIR}
  COPY --chmod=755 ./rootfs /
  EXPOSE 3000
  VOLUME ["/config"]
  ENTRYPOINT [ "/init" ]
  