@@ -14,18 +14,14 @@ RUN mkdir -p $PIP_CACHE_DIR
1414ARG USERNAME
1515LABEL org.opencontainers.image.source=https://github.com/OpenJKSoftware/python-devcontainer
1616
17- # Install uv
18- COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
19- ENV UV_CACHE_DIR=/var/cache/uv \
20- UV_PYTHON_CACHE_DIR=/var/cache/uv/python \
21- UV_LINK_MODE=copy \
22- UV_COMPILE_BYTECODE=1
23- RUN set -x; mkdir -p $UV_CACHE_DIR && mkdir -p $UV_PYTHON_CACHE_DIR
24- RUN --mount=type=cache,target=/var/cache uv python install ${PYTHONVERSION} --default
17+ # Ensure Apt cache is kept between builds
18+ RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
2519
2620# Install Base Reqs
2721COPY scripts/install_base_deps.sh /tmp/
28- RUN /tmp/install_base_deps.sh
22+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
23+ --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
24+ /tmp/install_base_deps.sh
2925
3026# Create User and setup environment
3127RUN useradd --shell /usr/bin/zsh --create-home ${USERNAME} -u 1000 \
@@ -34,8 +30,17 @@ RUN useradd --shell /usr/bin/zsh --create-home ${USERNAME} -u 1000 \
3430 && chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
3531ENV EDITOR=nvim
3632
33+ # Sudo Support
34+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
35+ --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
36+ set -x; \
37+ apt-get -y install --no-install-recommends sudo \
38+ && echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
39+
3740# Fix Locale issues
38- RUN set -x; \
41+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
42+ --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
43+ set -x; \
3944 apt-get install locales -y --no-install-recommends \
4045 && echo "LC_ALL=en_US.UTF-8" >> /etc/environment \
4146 && echo "LANG=en_US.utf-8" >> /etc/environment \
@@ -47,11 +52,16 @@ RUN set -x; \
4752COPY known_hosts /root/.ssh/known_hosts
4853COPY --chown=${USERNAME}:${USERNAME} known_hosts /home/${USERNAME}/.ssh/known_hosts
4954
50- # Sudo Support
51- RUN set -x; \
52- apt-get -y install --no-install-recommends sudo \
53- && echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
55+ # Install uv
56+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
57+ ENV UV_CACHE_DIR=/var/cache/uv \
58+ UV_PYTHON_CACHE_DIR=/var/cache/uv/python \
59+ UV_LINK_MODE=copy \
60+ UV_COMPILE_BYTECODE=1
61+ RUN set -x; mkdir -p $UV_CACHE_DIR && mkdir -p $UV_PYTHON_CACHE_DIR
62+ RUN --mount=type=cache,target=/var/cache,sharing=locked uv python install ${PYTHONVERSION} --default
5463
64+ RUN apt autoremove --purge -y && apt clean -y
5565
5666# Non Root User
5767USER ${USERNAME}
@@ -63,6 +73,4 @@ RUN set -x ; \
6373 && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
6474COPY --chown=${USERNAME}:${USERNAME} .zshrc .zshrc
6575
66-
67- RUN sudo bash -c "rm -rf {./*,/tmp/*,/var/cache/apt/*,/var/lib/apt/lists/*,$PIP_CACHE_DIR/*}"
6876ENTRYPOINT [ "/usr/bin/zsh" ]
0 commit comments