Skip to content

Commit de16979

Browse files
committed
Use UV, Deno for faster setup of development container
1 parent 7e9a09d commit de16979

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

.devcontainer/Dockerfile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
ARG PYTHON_VERSION=3.10
1+
ARG PYTHON_VERSION=3.12
22
FROM mcr.microsoft.com/devcontainers/python:${PYTHON_VERSION}
33

4-
# Install Node.js and Yarn
5-
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
6-
apt-get install -y nodejs
4+
# Install UV and Deno
5+
RUN curl -fsSL https://deno.land/install.sh | sh
6+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
7+
RUN uv python pin $PYTHON_VERSION
8+
# create python virtual environment
9+
RUN uv venv /opt/venv --python $PYTHON_VERSION --seed
10+
# Add venv, deno to PATH for subsequent RUN commands and for the container environment
11+
ENV PATH="/opt/venv/bin:/root/.deno/bin:$PATH"
712

813
# Setup working directory
914
WORKDIR /workspace
1015

1116
# --- Python Server App Dependencies ---
12-
# Create Python virtual environment
13-
RUN python3 -m venv /opt/venv
14-
# Add venv to PATH for subsequent RUN commands and for the container environment
15-
ENV PATH="/opt/venv/bin:${PATH}"
16-
1717
# Copy files required for Python dependency installation.
1818
COPY pyproject.toml README.md ./
1919

@@ -26,15 +26,15 @@ ENV PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cpu https://abetlen.gi
2626
VERSION=0.0.0
2727
# Install Python dependencies from pyproject.toml in editable mode
2828
RUN sed -i "s/dynamic = \\[\"version\"\\]/version = \"$VERSION\"/" pyproject.toml && \
29-
pip install --no-cache-dir ".[dev]"
29+
uv sync --all-extras && \
30+
chown -R vscode:vscode /opt/venv
3031

3132
# --- Web App Dependencies ---
3233
# Copy web app manifest files
33-
COPY src/interface/web/package.json src/interface/web/yarn.lock /tmp/web/
34+
COPY src/interface/web/package.json src/interface/web/deno.json src/interface/web/deno.lock /tmp/web/
3435

3536
# Install web app dependencies
36-
# note: yarn will be available from the "features" in devcontainer.json
37-
RUN yarn install --cwd /tmp/web --cache-folder /opt/yarn-cache
37+
RUN cd /tmp/web && deno install
3838

3939
# The .venv and node_modules are now populated in the image.
4040
# The rest of the source code will be mounted by VS Code from your local checkout,

.devcontainer/devcontainer.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dockerfile": "Dockerfile",
55
"context": "..", // Build context is the project root
66
"args": {
7-
"PYTHON_VERSION": "3.10"
7+
"PYTHON_VERSION": "3.12"
88
}
99
},
1010
"forwardPorts": [
@@ -53,11 +53,6 @@
5353
"postCreateCommand": "scripts/dev_setup.sh --devcontainer",
5454
"features": {
5555
"ghcr.io/devcontainers/features/github-cli:1": {},
56-
"ghcr.io/devcontainers/features/node:1": {
57-
"version": "lts",
58-
"installYarnUsingApt": false,
59-
"nodeGypDependencies": true
60-
}
6156
},
6257
"remoteUser": "vscode"
6358
}

0 commit comments

Comments
 (0)