Reputation: 355
I have been fruitlessly searching the internet for 2 days now looking for a way to install postgresql-dev for 9.6 due to an extremely outdated dep I'm trying to run. Unfortunately, running the following Dockerfile commands:
FROM python:2.7-alpine
ENV PYTHONUNBUFFERED 1
RUN mkdir /app/
RUN mkdir ./app/logs/
RUN mkdir ./app/xxx/
WORKDIR /app/xxx/
ADD requirements.txt /app/xxx/
ADD ./ /app/xxx/
RUN apk --update add python py-pip openssl postgresql-dev ca-certificates py-openssl libffi-dev musl-dev openssl-dev wget build-base gcc python-dev py-pip jpeg-dev zlib-dev libx
ml2 libxslt-dev
ENV LIBRARY_PATH=/lib:/usr/lib
RUN pip install --upgrade pip setuptools
RUN pip install psycopg2==2.4.5
Gives me the following error:
Collecting psycopg2==2.4.5
Downloading https://files.pythonhosted.org/packages/36/77/894a5dd9f3f55cfc85682d3e6473ee5103d8d418b95baf4019fad3ffa026/psycopg2-2.4.5.tar.gz (719kB)
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
Error: could not determine PostgreSQL version from '11.2'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-UcoQQZ/psycopg2/
Which I understand means that I'm installing PostgreSQL 11.2 from postgresql-dev when I need 9.6. I cannot seem to find this apk anywhere, and running postgresql-dev=9.6.5 or its equivalents does not appear to work either.
Is there any way to get this version of postgresql-dev from python2.7 alpine (or any other docker)? I saw that there are postgres docker containers but I'm new to docker and couldn't get them running either (psycopg2 was completely unable to find their installations)
Upvotes: 6
Views: 12793
Reputation: 18541
The closest version to postgresql-dev
9.6.5 in Alpine repositories is 9.6.10-r0
, used in Alpine 3.5:
https://pkgs.alpinelinux.org/package/v3.5/main/x86_64/postgresql-dev
Regardless of your Alpine version, you could instruct apk to pick this exact version from the V3.5 apk repository:
apk add postgresql-dev=9.6.10-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.5/main
Upvotes: 4
Reputation: 3847
This works for me:
# Python 3.6 on Alpine linux, a snall secure flavor of linux
FROM python:3.6-alpine
# Add community repositories to install dependencies
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
# These dependencies are required for matplotlib and numpy
RUN apk --no-cache --update-cache add gcc freetype-dev libpng-dev musl-dev linux-headers g++ gfortran python3-dev
# This symlink fixes an error in numpy compilation
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
# Postgres libs and dependencies, plus python-ldap depdency
RUN apk --no-cache --update-cache add postgresql-libs postgresql-dev libffi-dev openldap-dev unixodbc-dev git
COPY requirements.txt /app_name/requirements.txt
RUN pip3 install --upgrade pip
RUN pip3 intall --upgrade setuptools
RUN pip3 install -r /app_name/requirements.txt # includes psycopg2==2.7.3.1
Perhaps you can translate that to work with python27?
(btw Python 2.7 is going away soon, FYI)
Upvotes: 0