Skip to content

Ubuntu24.04 Python3.11

Dockerfile
FROM ubuntu:24.04

RUN apt update && apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update

RUN apt install -y python3.11 python3.11-dev python3.11-distutils
RUN apt install -y python3-pip
RUN apt install -y make

RUN DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai apt-get -y install tzdata
ENV TZ=Asia/Shanghai

RUN python3.11 -m pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN ln -s /usr/bin/python3.11 /usr/bin/python
Makefile
IMAGE_TAG := u24p311
WORK_DIR  := /root/project
CACHE_DIR := /root/.cache
OUT_WORK_DIR := $(PWD)/project
OUT_CACHE_DIR := $(PWD)/__env_cache__

DOCKER_RUN := docker run \
--rm -it \
-v $(OUT_WORK_DIR):$(WORK_DIR) \
-v $(OUT_CACHE_DIR):$(CACHE_DIR) \
-w $(WORK_DIR) \
$(IMAGE_TAG)

build:
	@docker build . -t $(IMAGE_TAG)
bash:
	@$(DOCKER_RUN) /bin/bash
version:
	@$(DOCKER_RUN) uv version
	@$(DOCKER_RUN) uv run python -V
init:
	@$(DOCKER_RUN) uv init
install:
	@$(DOCKER_RUN) uv install
add:
	@$(DOCKER_RUN) uv add $(name)
remove:
	@$(DOCKER_RUN) uv remove $(name)
run:
	@$(DOCKER_RUN) uv run $(name)
shell
make version
# uv 0.6.3
# Python 3.11.11

Released under the MIT License.