Skip to content

Ubuntu22.04 Python3.10

Dockerfile
FROM ubuntu:22.04

RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt update

RUN apt install -y python3 python3-pip python3-dev
RUN apt install -y make

# for pgsql
# RUN apt install -y libpq-dev

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

RUN python3 -m pip install poetry -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN ln -s /usr/bin/python3 /usr/bin/python
Makefile
IMAGE_TAG := u22p310
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) poetry run python -V
init:
	@$(DOCKER_RUN) poetry init
install:
	@$(DOCKER_RUN) poetry install --no-root
add:
	@$(DOCKER_RUN) poetry add $(name)
remove:
	@$(DOCKER_RUN) poetry remove $(name)
run:
	@$(DOCKER_RUN) poetry run python $(name)
shell
make version
# Python 3.10.12

Released under the MIT License.