-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython.Dockerfile
50 lines (37 loc) · 1.64 KB
/
python.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM ubuntu:20.04@sha256:8e5c4f0285ecbb4ead070431d29b576a530d3166df73ec44affc1cd27555141b
ARG DEBIAN_FRONTEND=noninteractive
ARG PYTHON_VERSION
ARG PYTHON_VERSION_SHORT
ARG DOWNLOAD_URL=https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
RUN apt update && \
apt install -y curl wget software-properties-common default-jre locales git && \
useradd -d /home/container -m container
# additional dependencies for python
RUN apt update && \
apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
# download and install python
WORKDIR /tmp
RUN curl -sLO $DOWNLOAD_URL && \
tar -xf Python-$PYTHON_VERSION.tgz
WORKDIR /tmp/Python-$PYTHON_VERSION
RUN ./configure --enable-optimizations --enable-loadable-sqlite-extensions && \
make PROFILE_TASK="-m test.regrtest --pgo -j8" -j8 && \
make altinstall
# update python alternatives
RUN update-alternatives --install /usr/bin/python python /usr/local/bin/python$PYTHON_VERSION_SHORT 1 && \
update-alternatives --set python /usr/local/bin/python$PYTHON_VERSION_SHORT
# install pip
RUN python -m ensurepip --upgrade && \
python -m pip install --upgrade pip
# update pip alternatives
RUN update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip$PYTHON_VERSION_SHORT 1 && \
update-alternatives --set pip /usr/local/bin/pip$PYTHON_VERSION_SHORT
ENV USER container
ENV USER container
ENV HOME /home/container
WORKDIR /home/container
COPY ./python.entrypoint.sh /entrypoint.sh
CMD ["/bin/bash", "/entrypoint.sh"]