Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

docker install python

# Python
FROM ubuntu:18.04

ARG PYTHON_VERSION=3.9.1
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH $PATH:/usr/local/bin

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=aptcache1804 --mount=type=cache,target=/var/lib/apt,sharing=locked,id=aptcache1804 
    export DEBIAN_FRONTEND=noninteractive 
    && apt-get update -y 
    && apt-get install -y apt-utils sudo wget tar 

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=aptcache1804 --mount=type=cache,target=/var/lib/apt,sharing=locked,id=aptcache1804 
    export DEBIAN_FRONTEND=noninteractive 
    && apt-get update -y 
    && apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev

RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz 
    && tar -xf Python-${PYTHON_VERSION}.tgz
  
RUN cd Python-${PYTHON_VERSION} 
    && ls -la 
    && ./configure --enable-optimizations 
    && make -j 4 
    && make altinstall
    
RUN pip3 install requests asyncio

COPY ./entrypoint.py ./entrypoint.py

ENTRYPOINT python ./entrypoint.py
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #docker #install #python
ADD COMMENT
Topic
Name
2+3 =