Forked from BillRaymond/gist:b39ae5d862aa81a250b70b812bd5d1cc
Last active
July 11, 2024 18:59
-
-
Save pythoninthegrass/891b7ff86dd0661337723d4ea8d5a566 to your computer and use it in GitHub Desktop.
Dockerfile to build a specific version of Python and set it as the default using Deadsnakes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax=docker/dockerfile:1.7 | |
FROM ubuntu:20.04 | |
ARG PYTHON_VERSION="3.11" | |
ENV TZ=US/Chicago | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN <<EOF | |
#!/usr/bin/env bash | |
apt-get update -qq | |
apt-get install -qq --no-install-recommends -y \ | |
software-properties-common | |
add-apt-repository ppa:deadsnakes/ppa -y | |
apt-get update -qq | |
apt-get install -qq --no-install-recommends -y \ | |
python3-pip \ | |
python3.11 \ | |
python3.11-venv | |
apt-get clean | |
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
EOF | |
RUN update-alternatives --install \ | |
/usr/bin/python3 python /usr/bin/python${PYTHON_VERSION} 1 \ | |
&& update-alternatives --set python /usr/bin/python${PYTHON_VERSION} \ | |
&& update-alternatives --set python /usr/bin/python${PYTHON_VERSION} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment