Code-agent-v1 / Dockerfile
nakas's picture
Update Dockerfile
1aa3e81 verified
raw
history blame
1.48 kB
FROM python:3.9-slim
WORKDIR /app
# Install dependencies
RUN pip install --no-cache-dir \
jupyter \
notebook \
ipywidgets \
numpy \
pandas \
matplotlib \
seaborn \
scikit-learn \
transformers \
torch \
gradio
# Create a non-root user to run Jupyter
RUN useradd -m jupyter
RUN mkdir -p /app/notebooks && chown -R jupyter:jupyter /app
# Switch to non-root user
USER jupyter
# Copy example notebook
COPY --chown=jupyter:jupyter welcome.ipynb /app/notebooks/
# Expose port
EXPOSE 7860
# Create a script to run both servers
RUN echo '#!/bin/bash\n\
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --NotebookApp.token="" --NotebookApp.password="" --NotebookApp.allow_origin="*" --NotebookApp.disable_check_xsrf=True --notebook-dir=/app/notebooks &\n\
python -c "import gradio as gr; demo = gr.Interface(fn=lambda: None, inputs=[], outputs=[gr.HTML(\"<div style=\\\"text-align:center; padding:10px;\\\"><h2>Mobile-Friendly Jupyter Notebook</h2><p>The notebook interface will appear below:</p></div><iframe src=\\\"/proxy/8888/tree\\\" width=\\\"100%\\\" height=\\\"800px\\\" frameborder=\\\"0\\\" style=\\\"overflow:hidden;\\\"></iframe>\")], title=\"Jupyter Notebook\", css=\".gradio-container {max-width: 100% !important; padding: 0 !important;} .min-h-\[48rem\] {min-height: auto !important;}\"); demo.launch(server_port=7860, share=False)"\n' > /app/start.sh
RUN chmod +x /app/start.sh
# Start servers
CMD ["/app/start.sh"]