Ubuntu 20.04 + Python 3.10 + Pipenv

3427 ワード

Ubuntu 20.04 + Python 3.10 + Pipenv 環境のDockerfileを記す。説明なし。

FROM ubuntu:20.04

RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get dist-upgrade -y
RUN apt-get autoremove -y
RUN apt-get autoclean -y

RUN apt-get install -y gnupg2 curl
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa -y

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

# Bummer! install python 3.10 instad
RUN apt-get update -y
RUN apt-get install python3.10 -y

RUN python3.10 --version

RUN apt-get remove python-pip

RUN apt-get install python3.10-distutils -y
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

RUN pip --version

# to have python in /app/.venv/bin
ENV PIPENV_VENV_IN_PROJECT true

# use pipenv to use Pipfile instead of requirement.txt
RUN pip install pipenv

RUN mkdir /app
WORKDIR /app
ENV PATH /app/.venv/bin/:$PATH

# install python libraries
ADD Pipfile /app/
ADD Pipfile.lock /app/
RUN pipenv install

# lastly copy my python programs such as main.py
ADD . /app/

CMD python main.py