File size: 3,545 Bytes
136f9cf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
FROM i386/debian:buster-slim
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PATH="/root/.local/bin:$PATH"
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
git \
libzmq3-dev \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-setuptools \
python3-wheel \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip
RUN python3 -m pip install --no-cache-dir --upgrade pip
# Install core Jupyter components
RUN python3 -m pip install --no-cache-dir \
jupyter \
jupyterlab \
notebook \
voila
# Install data science libraries
RUN python3 -m pip install --no-cache-dir \
numpy \
pandas \
matplotlib \
scipy \
scikit-learn \
seaborn \
statsmodels
# Install file processing libraries
RUN python3 -m pip install --no-cache-dir \
openpyxl \
xlrd \
xlwt \
pyarrow \
fastparquet \
python-docx \
pdfminer.six \
beautifulsoup4 \
lxml \
pillow
# Install WASM-friendly packages
RUN python3 -m pip install --no-cache-dir \
pyodide-pack
# Set up workspace directory
WORKDIR /workspace
RUN mkdir -p /workspace/data
# Configure Jupyter
RUN mkdir -p /root/.jupyter && \
echo "c.NotebookApp.ip = '0.0.0.0'" >> /root/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.port = 8888" >> /root/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.open_browser = False" >> /root/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.allow_root = True" >> /root/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.token = ''" >> /root/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.password = ''" >> /root/.jupyter/jupyter_notebook_config.py
# Entry point script for WASM compatibility
COPY <<EOT /workspace/prepare_for_wasm.py
import os
import sys
import json
import subprocess
def collect_dependencies():
"""Collect all Python dependencies for WASM conversion"""
result = subprocess.run(
[sys.executable, "-m", "pip", "freeze"],
capture_output=True,
text=True
)
return result.stdout.strip().split('\n')
def create_manifest():
"""Create a manifest file for WASM conversion"""
deps = collect_dependencies()
manifest = {
"name": "jupyter-datascience-wasm",
"version": "1.0.0",
"description": "Jupyter notebook with data science libraries for WASM",
"dependencies": deps,
"main": "server.py",
"files": [
"server.py",
"/root/.jupyter/jupyter_notebook_config.py"
]
}
with open("/workspace/wasm_manifest.json", "w") as f:
json.dump(manifest, f, indent=2)
print("Created WASM manifest file at /workspace/wasm_manifest.json")
if __name__ == "__main__":
create_manifest()
print("Prepared environment for WASM conversion")
EOT
# Create a simple server script for the WASM environment
COPY <<EOT /workspace/server.py
#!/usr/bin/env python3
import os
import sys
from notebook.notebookapp import main
if __name__ == "__main__":
sys.exit(main())
EOT
# Make the server script executable
RUN chmod +x /workspace/server.py
# Prepare for WASM conversion
RUN python3 /workspace/prepare_for_wasm.py
# Expose the Jupyter port
EXPOSE 8888
# Set the default command to start the Jupyter server
CMD ["python3", "/workspace/server.py"] |