-
Notifications
You must be signed in to change notification settings - Fork 3
chore: Update setup for local development for Deepnote engineers #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OlegWock
wants to merge
5
commits into
main
Choose a base branch
from
oleh/blu-5266-improve-dx-for-developing-webapp-against-local-toolkit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40a871a
chore: Update setup for local development for Deepnote engineers
OlegWock 5ea3269
Merge branch 'main' into oleh/blu-5266-improve-dx-for-developing-weba…
OlegWock a3c03e6
Update doc slightly
OlegWock 75e6801
Update local setup to properly connect to s3fs
OlegWock ef88908
Address feedback & add tests
OlegWock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,57 @@ | ||
| ARG FROM_PYTHON_TAG | ||
| # Dockerfile for local development with hot-reload support | ||
| # This container expects the toolkit source to be mounted at /toolkit | ||
| # and installs it in editable mode for live code changes | ||
| # | ||
| # Build with: | ||
| # docker build -t deepnote/jupyter-for-local:local -f dockerfiles/jupyter-for-local-hotreload/Dockerfile . | ||
|
|
||
| ARG FROM_PYTHON_TAG=3.12 | ||
| FROM deepnote/python:${FROM_PYTHON_TAG} | ||
|
|
||
| ARG FROM_PYTHON_TAG | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Install system dependencies | ||
| RUN apt-get update && \ | ||
| apt-get install -y openjdk-17-jdk && \ | ||
| apt-get install --no-install-recommends -y \ | ||
| rsync \ | ||
| git \ | ||
| # Required for pymssql | ||
| freetds-dev \ | ||
| # Required for database connectivity through ODBC | ||
| unixodbc-dev \ | ||
| # Required for secure connections (SSL/TLS) | ||
| libssl-dev && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN pip install poetry==2.2.0 | ||
| # Install Poetry | ||
| RUN pip install --no-cache-dir poetry==2.2.0 | ||
|
|
||
| WORKDIR /deepnote-toolkit | ||
| # Configure Poetry to create virtualenv outside the mounted source directory | ||
| # - virtualenvs.in-project false: Never use .venv from mounted host directory | ||
| # - virtualenvs.path: Store venvs in container-local directory | ||
| RUN poetry config virtualenvs.in-project false && \ | ||
| poetry config virtualenvs.path /opt/venvs | ||
|
|
||
| ENV POETRY_NO_INTERACTION=1 \ | ||
| POETRY_VIRTUALENVS_CREATE=1 \ | ||
| POETRY_VIRTUALENVS_IN_PROJECT=0 \ | ||
| POETRY_CACHE_DIR=/tmp/poetry_cache | ||
| # Create toolkit directory (will be mounted over, but needed for initial setup) | ||
| RUN mkdir -p /toolkit /opt/venvs | ||
|
|
||
| COPY pyproject.toml poetry.lock poetry.toml ./ | ||
| WORKDIR /toolkit | ||
|
|
||
| RUN poetry install --no-interaction --no-ansi --with server --with dev | ||
| # Environment variables for development mode | ||
| # POETRY_VIRTUALENVS_* ensures we never use host's .venv even if poetry.toml exists | ||
| ENV DEEPNOTE_RUNNING_IN_DEV_MODE=true \ | ||
| PYTHONDONTWRITEBYTECODE=1 \ | ||
| PYTHONUNBUFFERED=1 \ | ||
| POETRY_VIRTUALENVS_IN_PROJECT=false \ | ||
| POETRY_VIRTUALENVS_PATH=/opt/venvs | ||
|
|
||
| ENV PYTHONPATH=/deepnote-toolkit:/deepnote-toolkit/installer:$PYTHONPATH \ | ||
| TOOLKIT_BUNDLE_PATH=/deepnote-toolkit \ | ||
| TOOLKIT_VERSION="local-build" \ | ||
| USERNAME=user \ | ||
| PASSWORD=password \ | ||
| DEEPNOTE_RUNNING_IN_DEV_MODE=true \ | ||
| DEEPNOTE_WEBAPP_URL="http://host.docker.internal:3002" | ||
| # Copy the entrypoint script | ||
| COPY dockerfiles/jupyter-for-local-hotreload/entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| COPY dockerfiles/jupyter-for-local-hotreload/run-installer.sh /usr/local/bin/run-installer.sh | ||
| EXPOSE 8888 | ||
|
|
||
| ENTRYPOINT ["/usr/local/bin/run-installer.sh"] | ||
| ENTRYPOINT ["/entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # Entrypoint script for local development container | ||
| # Sets up filesystem mounts, installs toolkit in editable mode, and starts servers | ||
|
|
||
| echo "[local-toolkit] Starting local development environment..." | ||
|
|
||
| # Check if toolkit source is mounted | ||
| if [ ! -f "/toolkit/pyproject.toml" ]; then | ||
| echo "[local-toolkit] ERROR: Toolkit source not found at /toolkit" | ||
| echo "[local-toolkit] Make sure to mount the deepnote-toolkit directory to /toolkit" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Wait for s3fs mount to be available (created by localstack container) | ||
| echo "[local-toolkit] Waiting for /deepnote-mounts/s3fs to be created..." | ||
| while [ ! -d /deepnote-mounts/s3fs ]; do | ||
| sleep 2 | ||
| done | ||
| echo "[local-toolkit] /deepnote-mounts/s3fs is available" | ||
|
|
||
| mkdir -p /datasets | ||
| ln -sf /deepnote-mounts/s3fs /datasets/_deepnote_work | ||
| echo "[local-toolkit] Created /datasets/_deepnote_work symlink" | ||
|
|
||
| # Create /work symlink pointing to project-specific path | ||
| # In dev mode with PROJECT_ID, use project-specific path under s3fs | ||
| if [ -n "$PROJECT_ID" ]; then | ||
| PROJECT_WORK_PATH="/datasets/_deepnote_work/projects/${PROJECT_ID}" | ||
| mkdir -p "$PROJECT_WORK_PATH" | ||
| ln -sf "$PROJECT_WORK_PATH" /work | ||
| echo "[local-toolkit] Created /work -> $PROJECT_WORK_PATH symlink" | ||
| else | ||
| ln -sf /datasets/_deepnote_work /work | ||
| echo "[local-toolkit] Created /work -> /datasets/_deepnote_work symlink" | ||
| fi | ||
|
|
||
| cd /toolkit | ||
|
|
||
| # Install dependencies and toolkit in editable mode | ||
| echo "[local-toolkit] Installing toolkit in editable mode..." | ||
| poetry install --extras server --no-interaction | ||
|
|
||
| echo "[local-toolkit] Starting servers from /work directory..." | ||
|
|
||
| # Create log directory and start tailing the log file in background | ||
| # This makes toolkit logs visible in docker container output | ||
| LOG_FILE="/root/.local/state/deepnote-toolkit/logs/helpers.log" | ||
| mkdir -p "$(dirname "$LOG_FILE")" | ||
| touch "$LOG_FILE" | ||
| tail -f "$LOG_FILE" & | ||
| TAIL_PID=$! | ||
|
|
||
| # Clean up tail process on exit | ||
| cleanup() { | ||
| if kill -0 "$TAIL_PID" 2>/dev/null; then | ||
| kill "$TAIL_PID" 2>/dev/null || true | ||
| fi | ||
| } | ||
| trap cleanup EXIT SIGINT SIGTERM | ||
|
|
||
| # Configure Jupyter to use /work as its root directory | ||
| # This is picked up by the config loader and passed to Jupyter's --ServerApp.root_dir | ||
| export DEEPNOTE_PATHS__NOTEBOOK_ROOT=/work | ||
|
|
||
| cd /work | ||
|
|
||
| # Run server in foreground (not exec) so trap can clean up tail process | ||
| poetry --directory /toolkit run deepnote-toolkit server "$@" | ||
| exit $? | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.