-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDockerfile.dev
More file actions
46 lines (40 loc) · 1.77 KB
/
Copy pathDockerfile.dev
File metadata and controls
46 lines (40 loc) · 1.77 KB
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
# 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