|
1 | 1 | # https://github.com/devcontainers/images/tree/main/src/python
|
2 |
| -FROM mcr.microsoft.com/devcontainers/python:1-3.13-bookworm |
| 2 | +#FROM mcr.microsoft.com/devcontainers/python:1-3.13-bookworm |
| 3 | +FROM python:3.13-slim-bookworm |
| 4 | + |
| 5 | +# https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user |
| 6 | +ARG USERNAME=vscode |
| 7 | +ARG USER_UID=1000 |
| 8 | +ARG USER_GID=$USER_UID |
| 9 | + |
| 10 | +# Create the user |
| 11 | +RUN groupadd --gid $USER_GID $USERNAME \ |
| 12 | + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME --shell /bin/bash \ |
| 13 | + # [Optional] Add sudo support. Omit if you don't need to install software after connecting. |
| 14 | + && apt-get update \ |
| 15 | + && apt-get install -y sudo \ |
| 16 | + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ |
| 17 | + && chmod 0440 /etc/sudoers.d/$USERNAME |
3 | 18 |
|
4 | 19 | # Install additional packages.
|
5 |
| -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ |
6 |
| -# && apt-get -y install --no-install-recommends \ |
7 |
| -# <your-package-list-here> \ |
8 |
| -# && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* |
| 20 | +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ |
| 21 | + && apt-get -y install --no-install-recommends \ |
| 22 | + git \ |
| 23 | + make \ |
| 24 | + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* |
9 | 25 |
|
10 | 26 | # Install the project into `/app`
|
11 | 27 | WORKDIR /app
|
12 | 28 |
|
13 | 29 | # Enable bytecode compilation
|
14 |
| -ENV UV_COMPILE_BYTECODE=1 |
| 30 | +ENV UV_COMPILE_BYTECODE=1 \ |
| 31 | + UV_LINK_MODE=copy |
15 | 32 |
|
16 | 33 | # Install UV / UVX
|
17 | 34 | COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
18 | 35 |
|
19 | 36 | # Install project dependencies
|
20 |
| -RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
21 |
| - --mount=type=bind,source=uv.lock,target=uv.lock \ |
22 |
| - uv sync --frozen --no-install-project --all-groups |
| 37 | +COPY pyproject.toml uv.lock ./ |
| 38 | +RUN uv sync --frozen --no-install-project --all-groups \ |
| 39 | + && rm pyproject.toml uv.lock \ |
| 40 | + && chown -R $USERNAME:$USERNAME /app |
23 | 41 |
|
24 | 42 | # Place executables in the environment at the front of the path
|
25 | 43 | ENV PATH="/app/.venv/bin:$PATH"
|
| 44 | + |
| 45 | +# HACK: https://github.com/sphinx-doc/sphinx/issues/11739 |
| 46 | +ENV LC_ALL=C.UTF-8 |
| 47 | + |
| 48 | +# [Optional] Set the default user. Omit if you want to keep the default as root. |
| 49 | +USER $USERNAME |
0 commit comments