############################################################ # Hugging Face Space — Amazon Linux 2023 + Python 3.12 + Jupyter Lab ############################################################ FROM amazonlinux:2023 # ───────────────────────────── # 0️⃣ Environment variables # ───────────────────────────── ENV TZ=Europe/Paris \ LANG=en_US.UTF-8 \ LC_ALL=en_US.UTF-8 \ PYTHONUNBUFFERED=1 # ───────────────────────────── # 1️⃣ System packages + Python 3.12 # ───────────────────────────── RUN yum -y update && \ yum -y install --allowerasing \ sudo \ curl-minimal \ wget \ git \ unzip \ zip \ which \ tar \ shadow-utils \ procps-ng \ nano \ vim \ bzip2 \ gcc \ gcc-c++ \ make \ glibc-langpack-en \ libX11 \ openssl \ ca-certificates \ libsndfile \ python3.12 \ python3.12-pip && \ yum clean all && \ alternatives --install /usr/bin/python python /usr/bin/python3.12 1 && \ alternatives --install /usr/bin/pip pip /usr/bin/pip3.12 1 # ───────────────────────────── # 2️⃣ Node.js 21 + configurable-http-proxy # ───────────────────────────── RUN curl -sL https://rpm.nodesource.com/setup_21.x | bash - && \ yum install -y nodejs && \ npm install -g configurable-http-proxy && \ yum clean all # ───────────────────────────── # 3️⃣ Create non‑root user # ───────────────────────────── RUN useradd -m user && echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user ENV HOME=/home/user USER user # >>> ADD THIS LINE <<< ENV PATH="$HOME/.local/bin:$PATH" # ───────────────────────────── # 4️⃣ Workspace & working directory # ───────────────────────────── RUN mkdir -p $HOME/app $HOME/.cache $HOME/.config && chmod -R 777 $HOME WORKDIR $HOME/app # ───────────────────────────── # 5️⃣ Install Python packages (including JupyterLab) # ───────────────────────────── # ───────────────────────────── # 5️⃣ Install Python packages (including JupyterLab + Ansible) # ───────────────────────────── COPY --chown=user requirements.txt ./requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir jupyterlab ansible-core # ───────────────────────────── # 6️⃣ Extra packages + startup logic (as root) # ───────────────────────────── USER root COPY packages.txt /root/packages.txt RUN xargs -r -a /root/packages.txt yum install -y && yum clean all COPY on_startup.sh /root/on_startup.sh RUN chmod +x /root/on_startup.sh && /root/on_startup.sh RUN mkdir -p /data && chown user:user /data # ───────────────────────────── # 7️⃣ Copy project files # ───────────────────────────── USER user COPY --chown=user . $HOME/app # Optional: override Jupyter login UI COPY --chown=user login.html /home/user/.local/lib/python3.12/site-packages/jupyter_server/templates/login.html RUN chmod +x start_server.sh # ───────────────────────────── # 8️⃣ Runtime Environment # ───────────────────────────── ENV GRADIO_ALLOW_FLAGGING=never \ GRADIO_NUM_PORTS=1 \ GRADIO_SERVER_NAME=0.0.0.0 \ GRADIO_THEME=huggingface \ SYSTEM=spaces # 🚀 Launch JupyterLab on $PORT (required by Hugging Face) CMD ["./start_server.sh"]