具有高山,共享库缺失的Django dockerfile

时间:2018-08-09 14:44:16

标签: python django docker alpine

我正在尝试为我的django服务器创建一个dockerfile。

这是我的dockerfile:

FROM python:3.6-alpine3.7

# Copy in your requirements file
ADD requirements-pip.txt /requirements-pip.txt

RUN set -ex \
    && apk add --no-cache --virtual .build-deps \
            gcc \
            make \
            libc-dev \
            musl-dev \
            linux-headers \
            pcre-dev \
            libffi-dev \
            jpeg-dev \
            libxml2-dev \
            libxslt-dev \
            openblas-dev \
            gfortran \
            build-base \
            freetype-dev \
            libpng-dev \
            llvm-dev \
            postgresql-dev \
    && python3.6 -m venv /venv \
    && /venv/bin/pip install -U pip \
    && LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "/venv/bin/pip install --no-cache-dir -r /requirements-pip.txt" \
    && runDeps="$(\
            scanelf --needed --nobanner --recursive /venv \
                    | awk '{ gsub(/,/, "\nso:", $2 }' \
                    | sort -u \
                    | xargs -r apk info --installed \
                    | sort -u \
    )" \
    && apk add --virtual .python-rundeps $runDeps \
    && apk del .build-deps

# Copy your application code to the container (make sure you create a .dockerignore file if any large files or directories should be excluded)

RUN mkdir /code/
WORKDIR /code/
ADD . /code/

# uWSGI will listen on this port
EXPOSE 8000
# Add any custom, static environment variables needed by Django or your settings file here:
ENV DJANGO_SETTINGS_MODULE=myapp.settings

# uWSGI configuration (customize as needed):
ENV UWSGI_VIRTUALENV=/venv UWSGI_WSGI_FILE=./myapp/wsgi.py UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_WORKERS=2 UWSGI_THREADS=8 UWSGI_UID=1000 UWSGI_GID=2000 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy
# Call collectstatic (customize the following line with the minimal environment variables needed for manage.py to run):
#RUN DATABASE_URL=none python3.6 manage.py collectstatic --noinput

# Start uWSGI
#CMD ["/venv/bin/uwsgi", "--http-auto-chunkedclear", "--http-keepalive"]
#CMD ["/venv/bin/python3.6", "manage.py", "runserver"]
CMD ["/venv/bin/python3.6", "manage.py", "runserver", "0.0.0.0:8000"]

但是,当我运行我的映像时,缺少了psycopg2所需的共享库(libpq.so.5)。

因此,我认为当删除Alpine依赖项时,共享库也会被删除,但是有一种方法可以删除依赖项以减小映像大小,而无需删除位于/ usr / lib /中的共享库。文件夹。

0 个答案:

没有答案