-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.3.9
50 lines (41 loc) · 2.01 KB
/
Dockerfile.3.9
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
ARG ARCH=
ARG BASE_TAG=2023
ARG BASE_IMAGE=public.ecr.aws/amazonlinux/amazonlinux:${BASE_TAG}
ARG PY_VERSION=3.9.17
FROM $BASE_IMAGE as updates
RUN dnf upgrade -y; dnf clean packages; dnf clean headers; dnf clean metadata; dnf clean all; rm -rfv /var/cache/dnf
FROM updates as pybuild
WORKDIR /opt
ADD https://www.python.org/ftp/python/3.9.17/Python-3.9.17.tgz /opt/Python-3.9.17.tgz
RUN dnf upgrade -y; dnf groupinstall "Development tools" -y
RUN dnf install tar gzip xz -y
RUN dnf install -y openssl openssl-devel bzip2-devel libffi-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel libpcap-devel xz-devel expat-devel
RUN dnf install -y ncurses-c++-libs ncurses-compat-libs ncurses-devel ncurses-libs ncurses-static
RUN mkdir /opt/python -p
RUN tar xzf Python-3.9.17.tgz
ENV LDFLAGS="-L/opt/local/lib"
ENV CFLAGS="-I/opt/local/include"
WORKDIR /opt/Python-3.9.17
RUN ./configure --prefix=/opt/python --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions --enable-optimizations
ARG CPU_COUNT="-j 1"
RUN make ${CPU_COUNT} && make altinstall
RUN cd /opt && tar cf - python | xz -z - > /opt/build-Python-3.9.17.tar.xz
FROM $BASE_IMAGE
WORKDIR /opt
COPY --from=pybuild /opt/build-Python-3.9.17.tar.xz /opt/build-Python-3.9.17.tar.xz
ENV PATH=/opt/python/bin:$PATH
RUN dnf upgrade -y; dnf install -y openssl11-libs; dnf install make tar xz gzip -y;\
ls /opt;\
tar xfJ build-Python-3.9.17.tar.xz;\
rm -rfv build-Python-3.9.17.tar.xz;\
find /opt/python -name "*.pyc" -delete -print;\
rm -rfv /opt/python/lib/python3.9/test;\
dnf history undo last -y; dnf autoremove -y; dnf clean packages; dnf clean headers; dnf clean metadata; dnf clean all; rm -rfv /var/cache/dnf;\
(pip --version && pip install --no-cache-dir pip -U) || curl -sq https://bootstrap.pypa.io/get-pip.py | /opt/python/bin/python3.9 ;\
pip install setuptools -U
RUN ln -s /opt/python/bin/python3.9 /usr/bin/python
WORKDIR /
MAINTAINER [email protected]
LABEL runtime=python
LABEL version=3.9
CMD ["python"]