Skip to content
Merged
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
46 changes: 46 additions & 0 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# USAGE:
# This file will be used by the VS Code DevContainer extension
# to create a development environment for the mdio-python project.
# HOW TO MANUALLY BUILD AND DEBUG THE CONTAINER
# docker build -t mdio-dev -f .devcontainer/Dockerfile.dev .
# docker run -it --rm --entrypoint /bin/bash --name mdio-dev mdio-dev
# NOTES:
# 1. The container will be run as the non-root user 'vscode' with UID 1000.
# 2. The virtual environment will be setup at /home/vscode/.venv
# 3. The project source code will be host-mounted at /workspaces/mdio-python
ARG PYTHON_VERSION="3.13"
ARG LINUX_DISTRO="bookworm"
ARG UV_VERSION="0.6.11"
FROM mcr.microsoft.com/devcontainers/python:1-${PYTHON_VERSION}-${LINUX_DISTRO}

ENV USERNAME="vscode"
USER $USERNAME

COPY --chown=$USERNAME:$USERNAME ./ /workspaces/mdio-python

WORKDIR /workspaces/mdio-python

ARG UV_VERSION
# Install UV as described in https://devblogs.microsoft.com/ise/dockerizing-uv/
RUN python3 -m pip install --no-cache-dir uv==${UV_VERSION}
# Prevent uv from trying to create hard links, which does not work in a container
# that mounts local file systems (e.g. VS Code Dev Containers)
ENV UV_LINK_MODE=copy
# Add path to the site-packages
ENV PYTHONUSERBASE=/home/$USERNAME/.local
ENV PATH="$PYTHONUSERBASE/bin:$PATH"

# Initialize virtual environment in the container
ENV VIRTUAL_ENV="/home/$USERNAME/.venv"
ENV UV_PROJECT_ENVIRONMENT=$VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN uv venv $VIRTUAL_ENV

# Install the project in the editable mode
# https://setuptools.pypa.io/en/latest/userguide/development_mode.html
# This allows for live reloading of the code during development
RUN uv pip install -e .
# Install "extras" (development dependencies) in pyproject.toml
RUN uv sync --group dev
# Now one can run:
# pre-commit run --all-files
21 changes: 12 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"build": {
"dockerfile": "Dockerfile",
"dockerfile": "Dockerfile.dev",
"context": ".."
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": {
"post_create_script": "bash ./.devcontainer/post-install.sh"
// "post_create_script": "bash ./.devcontainer/post-install.sh"
},
// Forward 8787 to enable us to view dask dashboard
"forwardPorts": [8787],
Expand All @@ -16,8 +16,9 @@
// Configure properties specific to VS Code.
"vscode": {
"settings": {
"python.terminal.activateEnvInCurrentTerminal": true,
"python.defaultInterpreterPath": "/opt/venv/bin/python"
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
},
"extensions": [
"ms-python.python",
Expand All @@ -27,17 +28,19 @@
"ms-toolsai.jupyter-renderers",
"vscode-icons-team.vscode-icons",
"wayou.vscode-todo-highlight",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"visualstudioexptteam.vscodeintellicode",
"richie5um2.vscode-sort-json"
]
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",
"updateRemoteUserUID": true,
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/mdio-python,type=bind",
"workspaceFolder": "/workspaces/mdio-python",
"mounts": [
// Re-use local Git configuration
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig_tmp,type=bind,consistency=cached",
"source=${localEnv:HOME}/.gitconfig,target=/root/.gitconfig_tmp,type=bind,consistency=cached",
"source=${localEnv:SCRATCH_DIR}/${localEnv:USER},target=/scratch/,type=bind,consistency=cached"
// "source=${localWorkspaceFolder}/../DATA/,target=/DATA/,type=bind,consistency=cached"
]
}
Loading