Ubuntu20.04 Python3.8
Dockerfile
FROM ubuntu:20.04
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt update
# RUN apt-get update --fix-missing
RUN DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai apt-get -y install tzdata
ENV TZ=Asia/Shanghai
RUN apt install -y python3.8 python3.8-dev python3-pip
RUN apt install -y make
# for pgsql
# RUN apt install -y libpq-dev
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN python -m pip install poetry -i https://pypi.tuna.tsinghua.edu.cn/simple
Makefile
IMAGE_TAG := u20p38
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) \
--net=host \
$(IMAGE_TAG)
build:
@docker build . -t $(IMAGE_TAG)
up:
@docker-compose up -d && docker-compose logs -f
down:
@docker-compose down
logs:
@docker-compose logs -f
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)
tests_env:
@$(DOCKER_RUN) poetry add --group dev pytest pytest-asyncio
tests:
@$(DOCKER_RUN) poetry run pytest tests.py
shell
make version
# Python 3.8