Spaces:
Sleeping
Sleeping
| FROM ubuntu:22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| TZ=Europe/Paris | |
| # Remove any third-party apt sources to avoid issues with expiring keys. | |
| # Install some basic utilities | |
| # Install all dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| mariadb-server \ | |
| curl \ | |
| redis-server \ | |
| python3 \ | |
| python3-pip \ | |
| python3-venv \ | |
| python3-setuptools \ | |
| python3-wheel \ | |
| git \ | |
| supervisor \ | |
| pkg-config \ | |
| nginx \ | |
| cron \ | |
| tzdata \ | |
| libcups2-dev \ | |
| libldap2-dev \ | |
| libsasl2-dev \ | |
| mariadb-client \ | |
| libmariadb-dev \ | |
| libmariadb-dev-compat \ | |
| gunicorn \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Upgrade pip and install bench | |
| RUN useradd -m -s /bin/bash frappe | |
| # Init bench as frappe user | |
| USER frappe | |
| WORKDIR /home/frappe | |
| RUN python3 -m venv py314 && . /home/frappe/py314/bin/activate && \ | |
| pip3 install --upgrade pip && pip3 install uv frappe-bench && \ | |
| uv python install 3.14 | |
| # Setup frappe user | |
| RUN . /home/frappe/py314/bin/activate && bench init frappe-bench --python /home/frappe/.local/bin/python3.14 | |
| # Get apps | |
| WORKDIR /home/frappe/frappe-bench | |
| RUN . /home/frappe/py314/bin/activate && bench get-app erpnext | |
| # Build assets | |
| RUN . /home/frappe/py314/bin/activate && bench build | |
| RUN adduser --disabled-password --gecos '' --shell /bin/bash user \ | |
| && chown -R user:user /app | |
| RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user | |
| USER user | |
| # All users can use /home/user as their home directory | |
| ENV HOME=/home/user | |
| RUN mkdir $HOME/.cache $HOME/.config \ | |
| && chmod -R 777 $HOME | |
| # Set up the Conda environment | |
| WORKDIR $HOME/app | |
| ####################################### | |
| # Start root user section | |
| ####################################### | |
| USER root | |
| # User Debian packages | |
| ## Security warning : Potential user code executed as root (build time) | |
| RUN --mount=target=/root/packages.txt,source=packages.txt \ | |
| apt-get update && \ | |
| xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \ | |
| bash /root/on_startup.sh | |
| RUN mkdir /data && chown user:user /data | |
| ####################################### | |
| # End root user section | |
| ####################################### | |
| #USER user | |
| # Python packages | |
| RUN --mount=target=requirements.txt,source=requirements.txt \ | |
| pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy the current directory contents into the container at $HOME/app setting the owner to the user | |
| COPY --chown=user . $HOME/app | |
| RUN chmod +x start_server.sh | |
| COPY --chown=user login.html /home/frappe/py314/lib/python3.10/site-packages/jupyter_server/templates/login.html | |
| ENV PYTHONUNBUFFERED=1 \ | |
| GRADIO_ALLOW_FLAGGING=never \ | |
| GRADIO_NUM_PORTS=1 \ | |
| GRADIO_SERVER_NAME=0.0.0.0 \ | |
| GRADIO_THEME=huggingface \ | |
| SYSTEM=spaces \ | |
| SHELL=/bin/bash | |
| RUN jupyter server 8989 | |
| RUN python -m http.server 8090 | |
| RUN rm -f /etc/nginx/sites-enabled/default | |
| COPY nginx-erpnext.conf /etc/nginx/sites-available/erpnext | |
| RUN ln -sf /etc/nginx/sites-available/erpnext /etc/nginx/sites-enabled/erpnext | |
| # Entrypoint | |
| #COPY entrypoint.sh /entrypoint.sh | |
| #RUN chmod +x /entrypoint.sh | |
| #RUN ["./start_server.sh"] | |
| CMD nginx | |