Folders next to the project, like a clone of another repository, can be created without root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.8 KiB
Docker
45 lines
1.8 KiB
Docker
# Keep the Python version in sync with the production Dockerfile
|
|
FROM python:3.15-slim-trixie
|
|
|
|
ARG USERNAME=dev
|
|
ARG USER_UID=1000
|
|
ARG USER_GID=$USER_UID
|
|
|
|
# git + openssh-client: git over the host's forwarded SSH agent
|
|
# gcc, libc-dev, libpq-dev: build psycopg2 from requirements.txt
|
|
# postgresql-client, wait-for-it: database scripts
|
|
# curl, ca-certificates: Claude Code installer
|
|
# vim, bash-completion: personal preferences
|
|
RUN apt-get -y update && \
|
|
apt-get install --no-install-recommends -y \
|
|
git openssh-client make curl ca-certificates sudo \
|
|
gcc libc-dev libpq-dev \
|
|
postgresql-client wait-for-it \
|
|
vim bash-completion && \
|
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Load bash-completion in every interactive shell (e.g. `make <TAB>`). Not in
|
|
# ~/.bashrc, since the home dir is a volume (see devcontainer.json).
|
|
RUN echo '. /usr/share/bash-completion/bash_completion' >> /etc/bash.bashrc
|
|
|
|
RUN groupadd --gid $USER_GID $USERNAME && \
|
|
useradd --uid $USER_UID --gid $USER_GID -m -s /bin/bash $USERNAME && \
|
|
echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME && \
|
|
chmod 0440 /etc/sudoers.d/$USERNAME
|
|
|
|
# Owned by the dev user so folders can be created next to the project. Docker
|
|
# would otherwise create it as root when bind mounting /workspaces/max.
|
|
RUN mkdir /workspaces && chown $USERNAME:$USERNAME /workspaces
|
|
|
|
# Project venv, owned by the dev user so pip works without sudo
|
|
ENV VIRTUAL_ENV=/opt/venv
|
|
RUN python -m venv $VIRTUAL_ENV && chown -R $USERNAME:$USERNAME $VIRTUAL_ENV
|
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
|
|
USER $USERNAME
|
|
|
|
# Claude Code (native installer, lands in ~/.local). The home dir is a volume
|
|
# (see devcontainer.json); Claude then updates itself inside that volume.
|
|
RUN curl -fsSL https://claude.ai/install.sh | bash
|
|
ENV PATH="/home/$USERNAME/.local/bin:$PATH"
|