Installing postgresql-dev for Postgres 9.6.x in a Dockerfile?
由于我正在尝试运行一个非常过时的 dep,我已经在互联网上搜索了 2 天,现在正在寻找一种为 9.6 安装 postgresql-dev 的方法。不幸的是,运行以下 Dockerfile 命令:
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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 |
给我以下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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/ |
我理解这意味着当我需要 9.6 时,我正在从 postgresql-dev 安装 PostgreSQL 11.2。我似乎在任何地方都找不到这个 apk,并且运行 postgresql-dev=9.6.5 或其等效项似乎也不起作用。
有没有办法从 python2.7 alpine(或任何其他 docker)获取这个版本的 postgresql-dev?我看到有 postgres docker 容器,但我是 docker 新手,也无法让它们运行(psycopg2 完全找不到它们的安装)
Alpine 存储库中与
https://pkgs.alpinelinux.org/package/v3.5/main/x86_64/postgresql-dev
无论您的 Alpine 版本如何,您都可以指示 apk 从 V3.5 apk 存储库中选择这个确切的版本:
1 | apk ADD postgresql-dev=9.6.10-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.5/main |
这对我有用:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 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 |
也许您可以将其翻译为与 python27 一起使用?
(顺便说一句,Python 2.7 即将消失,仅供参考)