|
1 | 1 | # The devcontainer should use the developer target and run as root with podman |
2 | 2 | # or docker with user namespaces. |
3 | 3 | ARG PYTHON_VERSION=3.11 |
| 4 | + |
| 5 | +# The developer is used by devcontainers ############################################### |
4 | 6 | FROM python:${PYTHON_VERSION} AS developer |
5 | 7 |
|
6 | 8 | # Add any system dependencies for the developer/build environment here |
7 | 9 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 10 | + gdb \ |
| 11 | + busybox \ |
8 | 12 | graphviz \ |
9 | | - && rm -rf /var/lib/apt/lists/* |
| 13 | + && rm -rf /var/lib/apt/lists/* \ |
| 14 | + && busybox --install -s |
10 | 15 |
|
11 | 16 | # Set up a virtual environment and put it in PATH |
12 | 17 | RUN python -m venv /venv |
13 | 18 | ENV PATH=/venv/bin:$PATH |
14 | 19 |
|
15 | | -# The build stage installs the context into the venv |
| 20 | +# The build stage installs the context into the venv ################################### |
16 | 21 | FROM developer AS build |
| 22 | + |
17 | 23 | # Requires buildkit 0.17.0 |
18 | 24 | COPY --chmod=o+wrX . /workspaces/fastcs-example |
19 | 25 | WORKDIR /workspaces/fastcs-example |
20 | | -RUN touch dev-requirements.txt && pip install -c dev-requirements.txt .[demo] |
| 26 | +RUN touch dev-requirements.txt && pip install stdio-socket>=1.3.1 debugpy \ |
| 27 | + -c dev-requirements.txt .[demo] |
| 28 | + |
| 29 | +# The debug stage allows for debugging and development ################################# |
| 30 | +FROM build AS debug |
| 31 | + |
| 32 | +# Set origin to use ssh |
| 33 | +RUN git remote set-url origin [email protected]:DiamondLightSource/fastcs-example.git |
| 34 | + |
| 35 | +# Make editable and debuggable |
| 36 | +RUN pip install debugpy -e '.[dev]' |
| 37 | +RUN chmod o+wrX /venv /workspaces |
21 | 38 |
|
| 39 | +RUN apt-get update && \ |
| 40 | + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 41 | + busybox \ |
| 42 | + gdb \ |
| 43 | + libnss-ldapd \ |
| 44 | + && rm -rf /var/lib/apt/lists/* \ |
| 45 | + && busybox --install -s |
22 | 46 |
|
23 | | -# The runtime stage copies the built venv into a slim runtime container |
| 47 | +# For this pod to understand finding user information from LDAP |
| 48 | +RUN sed -i 's/files/ldap files/g' /etc/nsswitch.conf |
| 49 | + |
| 50 | +# Alternate entrypoint to allow restarting the IOC |
| 51 | +ENTRYPOINT [ "/bin/bash", "-c", "sleep infinity" ] |
| 52 | + |
| 53 | +# The runtime stage has built venv only ################################################ |
24 | 54 | FROM python:${PYTHON_VERSION}-slim AS runtime |
25 | | -# Add apt-get system dependecies for runtime here if needed |
| 55 | + |
| 56 | +# Add apt-get system dependecies for runtime |
| 57 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 58 | + gdb \ |
| 59 | + && rm -rf /var/lib/apt/lists/* |
| 60 | + |
26 | 61 | COPY --from=build /venv/ /venv/ |
27 | 62 | ENV PATH=/venv/bin:$PATH |
28 | 63 |
|
|
0 commit comments