Skip to content

Commit ba2fec9

Browse files
authored
Switch base image to debian and install mise; add py-init helper
Replace FROM python:latest with FROM debian:latest and install curl, ca-certificates, bash and git. Install mise and add it to PATH, enable activation in /etc/profile.d/mise.sh and root's .bashrc. Add /etc/profile.d/py-init.sh which provides a py-init() helper to initialize mise-managed Python environments (sets mise.toml, venv path and auto-create). Export the function and ensure non-interactive shells source it via BASH_ENV. Set global mise Python to 3.13 and set WORKDIR to /workspace. CMD remains bash.
1 parent afa2696 commit ba2fec9

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

.devcontainer/docker/Dockerfile

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
From python:latest
1+
FROM debian:latest
2+
3+
RUN apt-get update \
4+
&& apt-get install -y --no-install-recommends \
5+
curl \
6+
ca-certificates \
7+
bash \
8+
git \
9+
&& rm -rf /var/lib/apt/lists/* \
10+
&& curl -fsSL https://mise.run | sh \
11+
&& ~/.local/bin/mise --version || true
12+
13+
ENV PATH="/root/.local/bin:${PATH}"
14+
15+
RUN echo 'eval "$(/root/.local/bin/mise activate bash)"' > /etc/profile.d/mise.sh \
16+
&& chmod +x /etc/profile.d/mise.sh || true \
17+
&& echo 'eval "$(/root/.local/bin/mise activate bash)"' >> /root/.bashrc
18+
19+
# Provide a convenient py-init() helper for initializing a mise Python
20+
# environment. Place it in /etc/profile.d so login shells get it, export
21+
# the function so child bash processes see it, and set BASH_ENV so
22+
# non-interactive bash shells source it too. Also source it from
23+
# /root/.bashrc to ensure interactive non-login shells get it.
24+
RUN cat > /etc/profile.d/py-init.sh <<'PYINIT'
25+
py-init() {
26+
if [ -z "$1" ]; then
27+
echo "Error: Please provide a Python version."
28+
echo "Example: py-init 3.11"
29+
return 1
30+
fi
31+
32+
echo "Initializing mise Python environment for version $1..."
33+
34+
touch ./mise.toml
35+
mise use python@$1
36+
mise config set env._.python.venv.path .venv
37+
mise config set env._.python.venv.create true
38+
39+
echo "Setup complete."
40+
}
41+
export -f py-init
42+
PYINIT
43+
44+
RUN chmod 0755 /etc/profile.d/py-init.sh \
45+
&& echo 'source /etc/profile.d/py-init.sh' >> /root/.bashrc || true
46+
47+
# Ensure non-interactive bash shells source the py-init helper
48+
ENV BASH_ENV=/etc/profile.d/py-init.sh
49+
50+
RUN /root/.local/bin/mise use --global python@3.13
51+
52+
WORKDIR /workspace
53+
54+
CMD ["bash"]

0 commit comments

Comments
 (0)