Skip to content
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

Add Dev Containers config #2255

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node:1": {}
},

"forwardPorts": [4141, 4142],

"portsAttributes": {
"4142": {
"label": "Backend",
"onAutoForward": "notify"
},
"4141": {
"label": "Frontend",
"onAutoForward": "openBrowser"
}
},

"containerEnv": {
"DISPLAY": "dummy",
"PYTHONUNBUFFERED": "True",
"UV_LINK_MODE": "copy",
"VIRTUAL_ENV": "/home/vscode/venv"
},

// FIXME: Why does it say "Property build is not allowed" despite it being part of the standard and the docs?
// https://containers.dev/implementors/json_reference/#image-specific
// https://code.visualstudio.com/docs/devcontainers/create-dev-container#_dockerfile
"build": {
"args": {
"NODE_VERSION": "18"
}
},

"onCreateCommand": "./.devcontainer/onCreateCommand.sh",

"postStartCommand": {
"backend": "nohup bash -c 'uv run python package/kedro_viz/server.py demo-project &' > backend.out 2> backend.err < /dev/null",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little confused why this happens, from where does it get the build files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's getting them from the published version 😓

// FIXME: Looks like the frontend is not needed? The backend stands on its own
"frontend": "nohup bash -c 'npm start &' > frontend.out 2> frontend.err"
},

"customizations": {
"vscode": {
"extensions": [
"ms-python.python"
]
}
}
}
16 changes: 16 additions & 0 deletions .devcontainer/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /usr/bin/env bash

# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

uv venv $VIRTUAL_ENV

uv pip install -r package/test_requirements.txt -r demo-project/src/docker_requirements.txt
uv pip install -e package/

# Now the NPM dependencies too
npm install
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ coverage.xml

# Kedro
*.log

.venv/
Loading