Skip to content

Instantly share code, notes, and snippets.

@AlmogCohen
Last active June 26, 2023 00:23
Show Gist options
  • Save AlmogCohen/e9e0667e875f955e0d4783b7433ed604 to your computer and use it in GitHub Desktop.
Save AlmogCohen/e9e0667e875f955e0d4783b7433ed604 to your computer and use it in GitHub Desktop.
Dockerfile for Centos 6.10 with python 3.7 + pip + Pipenv
############################################################
# Dockerfile to build CentOS linux server with python3.7
# Can also use centos:6.9 as the origin dockerfile
############################################################
FROM centos:6.10
MAINTAINER Almog Cohen
# Install yum dependencies
RUN yum -y update && \
yum groupinstall -y development && \
yum install -y \
bzip2-devel \
git \
hostname \
openssl \
openssl-devel \
sqlite-devel \
sudo \
tar \
wget \
zlib-dev \
libffi \
libffi-devel
# SSL Fix https://benad.me/blog/2018/07/17/python-3.7-on-centos-6/
RUN cd /tmp && \
wget 'https://www.openssl.org/source/openssl-1.1.0h.tar.gz' &&\
tar -xf openssl-1.1.0h.tar.gz &&\
cd openssl-1.1.0h &&\
./config shared --prefix=/usr/local/openssl11 --openssldir=/usr/local/openssl11 && make && make install
# End of SSL fix
# Install python3.7
RUN cd /tmp && \
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz && \
tar xvfz Python-3.7.3.tgz && \
cd Python-3.7.3 && \
# Fix the SSL headers https://benad.me/blog/2018/07/17/python-3.7-on-centos-6/
sed -i 's/SSL=\/usr\/local\/ssl/SSL=\/usr\/local\/openssl11/g' Modules/Setup.dist &&\
sed -i '211,214 s/^##*//' Modules/Setup.dist &&\
# End of SSL fix
LDFLAGS="-Wl,-rpath=/usr/local/openssl11/lib" \
./configure --prefix=/usr/local --enable-shared --with-openssl=/usr/local/openssl11 --with-system-ffi && \
make && \
make altinstall
# Update libraries bindings
RUN echo "/usr/local/lib" >> /etc/ld.so.conf
RUN ldconfig
# Update the default pip version shipped with python
RUN pip3.7 install --upgrade pip
# Install Pipenv and add to path
RUN pip3.7 install pipenv
@ITJamie
Copy link

ITJamie commented Aug 15, 2022

I needed to add --no-check-certificate to the wget on line 28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment