Skip to content

Commit 79dc252

Browse files
committed
Mount venv in workspace
1 parent 1e2ba20 commit 79dc252

2 files changed

Lines changed: 10 additions & 19 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"remoteEnv": {
1313
// Allow X11 apps to run inside the container
14-
"DISPLAY": "${localEnv:DISPLAY}"
14+
"DISPLAY": "${localEnv:DISPLAY}",
1515
},
1616
"customizations": {
1717
"vscode": {
@@ -38,14 +38,18 @@
3838
"source": "${localEnv:HOME}/.cache/uv",
3939
"target": "/.cache/uv",
4040
"type": "bind"
41+
},
42+
{
43+
"target": "/workspaces/blueapi/.venv",
44+
"type": "volume"
4145
}
4246
],
4347
"features": {
4448
// add in eternal history and other bash features
4549
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {}
4650
},
4751
// Create the config folder for the bash-config feature
48-
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config",
52+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config ${localEnv:HOME}/.cache/uv",
4953
"runArgs": [
5054
// Allow the container to access the host X11 display and EPICS CA
5155
"--net=host",

Dockerfile

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# or docker with user namespaces.
33
# Version SHA has been removed, see: https://github.com/DiamondLightSource/blueapi/issues/1053
44
ARG PYTHON_VERSION=3.11
5-
FROM python:${PYTHON_VERSION} AS developer
6-
COPY --from=ghcr.io/astral-sh/uv:0.7.17 /uv /uvx /bin/
5+
FROM ghcr.io/astral-sh/uv:0.7.19-bookworm AS developer
76

87
# Add any system dependencies for the developer/build environment here
98
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -17,23 +16,16 @@ RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/s
1716
./get_helm.sh; \
1817
rm get_helm.sh
1918

20-
# Set up a virtual environment and put it in PATH
21-
# TODO: uv setup env
22-
ENV UV_PROJECT_ENVIRONMENT=/venv
23-
# TODO: uv cache
2419
RUN mkdir -p /.cache/uv; chmod 777 /.cache/uv
2520
ENV UV_CACHE_DIR=/.cache/uv
26-
# RUN python -m venv /venv
27-
# ENV PATH=/venv/bin:$PATH
21+
RUN SHELL=/usr/bin/bash uv tool update-shell
2822

2923
# The build stage installs the context into the venv
3024
FROM developer AS build
31-
# RUN mkdir -p /.cache/pip; chmod 777 /.cache/pip
25+
3226
COPY --chmod=777 . /workspaces/blueapi
3327
WORKDIR /workspaces/blueapi
34-
# TODO: uv sync
3528
RUN uv sync --locked
36-
# RUN touch dev-requirements.txt && pip install --upgrade pip && pip install -c dev-requirements.txt .
3729

3830
FROM build AS debug
3931

@@ -46,11 +38,8 @@ RUN DEBIAN_FRONTEND=noninteractive apt install libnss-ldapd -y
4638
RUN sed -i 's/files/ldap files/g' /etc/nsswitch.conf
4739

4840
# Make editable and debuggable
49-
# TODO: uv tool install debugpy
5041
RUN uv tool install debugpy
5142
RUN uv tool install --editable .
52-
# RUN pip install debugpy
53-
# RUN pip install -e .
5443

5544
# Alternate entrypoint to allow devcontainer to attach
5645
ENTRYPOINT [ "/bin/bash", "-c", "--" ]
@@ -63,11 +52,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
6352
# Git required for installing packages at runtime
6453
git \
6554
&& rm -rf /var/lib/apt/lists/*
66-
# TODO: Update cache locations
67-
COPY --from=build --chmod=777 /venv/ /venv/
6855
COPY --from=build --chmod=777 /.cache/uv /.cache/uv
6956
COPY --from=build --chmod=777 /workspaces/blueapi /workspaces/blueapi
70-
ENV PATH=/venv/bin:$PATH
57+
ENV PATH=/workspaces/blueapi/.venv/bin:$PATH
7158
ENV UV_CACHE_DIR=/.cache/uv
7259
ENV PYTHONPYCACHEPREFIX=/tmp/blueapi_pycache
7360

0 commit comments

Comments
 (0)