((Cookiecutter-django)Raspberry Pi 4上的Docker部署:为什么构建失败?

问题描述 投票:0回答:1

我正在尝试在运行Rasbian的Raspberry Pi 4(Linux raspberrypi 4.19.97-v7l +)上使用cookiecutter-django部署一个小型Django应用dockerized。我会说我的设置非常原始,希望我不是唯一遇到这种情况的人。

cookiecutter == 1.7.2django == 3.0.5

构建失败,我尝试安装:

sudo apt-get install python3-dev libffi-dev libssl-dev openssl-dev build-essential

虽然没有帮助。运行时,我不断得到以下输出:

$ docker-compose -f production.yml build

输出

redis uses an image, skipping
Building postgres
Step 1/4 : FROM postgres:11.3
 ---> 9ff9cc2df728
Step 2/4 : COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
 ---> Using cache
 ---> 2ee1f827b4bb
Step 3/4 : RUN chmod +x /usr/local/bin/maintenance/*
 ---> Using cache
 ---> 861e846adc6b
Step 4/4 : RUN mv /usr/local/bin/maintenance/* /usr/local/bin     && rmdir /usr/local/bin/maintenance
 ---> Using cache
 ---> cb799d694f3e
Successfully built cb799d694f3e
Successfully tagged mysite_production_postgres:latest
Building django
Step 1/18 : FROM python:3.8-slim-buster
 ---> a852e8fce952
Step 2/18 : ENV PYTHONUNBUFFERED 1
 ---> Using cache
 ---> bfea44a6a6a9
Step 3/18 : RUN apt-get update   && apt-get install -y build-essential   && apt-get install -y libpq-dev   && apt-get install -y gettext   && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false   && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> df6cdd6db821
Step 4/18 : RUN addgroup --system django     && adduser --system --ingroup django django
 ---> Using cache
 ---> 3803ac7cd551
Step 5/18 : COPY ./requirements /requirements
 ---> Using cache
 ---> e6a184f5e700
Step 6/18 : RUN pip install --no-cache-dir -r /requirements/production.txt     && rm -rf /requirements
 ---> Running in 2394f8b40e4a
Collecting pytz==2020.1
  Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
Collecting python-slugify==4.0.0
  Downloading python-slugify-4.0.0.tar.gz (8.8 kB)
Collecting Pillow==7.1.2
  Downloading Pillow-7.1.2.tar.gz (38.9 MB)
Collecting rcssmin==1.0.6
  Downloading rcssmin-1.0.6.tar.gz (582 kB)
Collecting argon2-cffi==19.2.0
  Downloading argon2-cffi-19.2.0.tar.gz (1.8 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-g3gfug52/overlay --no-warn-script-location --no-binary psycopg2 --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.0'
       cwd: None
  Complete output (100 lines):
  Collecting setuptools>=40.6.0
    Downloading setuptools-46.3.0-py3-none-any.whl (582 kB)
  Collecting wheel
    Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
  Collecting cffi>=1.0
    Downloading cffi-1.14.0.tar.gz (463 kB)
  Collecting pycparser
    Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
  Building wheels for collected packages: cffi
    Building wheel for cffi (setup.py): started
    Building wheel for cffi (setup.py): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-53k9e4tn/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-53k9e4tn/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-jkqn8qyk
         cwd: /tmp/pip-install-53k9e4tn/cffi/
    Complete output (36 lines):
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-3.8
    creating build/lib.linux-armv7l-3.8/cffi
    copying cffi/cparser.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/recompiler.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/commontypes.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/verifier.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/pkgconfig.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/model.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/error.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/__init__.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/api.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/lock.py -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/_embedding.h -> build/lib.linux-armv7l-3.8/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-3.8/cffi
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-armv7l-3.8
    creating build/temp.linux-armv7l-3.8/c
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.8 -c c/_cffi_backend.c -o build/temp.linux-armv7l-3.8/c/_cffi_backend.o
    c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
     #include <ffi.h>
              ^~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for cffi
    Running setup.py clean for cffi
  Failed to build cffi
  Installing collected packages: setuptools, wheel, pycparser, cffi
      Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-53k9e4tn/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-53k9e4tn/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-x_f5jys4/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-g3gfug52/overlay --compile --install-headers /tmp/pip-build-env-g3gfug52/overlay/include/python3.8/cffi
           cwd: /tmp/pip-install-53k9e4tn/cffi/
      Complete output (36 lines):
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-3.8
      creating build/lib.linux-armv7l-3.8/cffi
      copying cffi/cparser.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/recompiler.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/commontypes.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/verifier.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/model.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/error.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/__init__.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/api.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/lock.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/_embedding.h -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-3.8/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-armv7l-3.8
      creating build/temp.linux-armv7l-3.8/c
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.8 -c c/_cffi_backend.c -o build/temp.linux-armv7l-3.8/c/_cffi_backend.o
      c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
       #include <ffi.h>
                ^~~~~~~
      compilation terminated.
      error: command 'gcc' failed with exit status 1
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-53k9e4tn/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-53k9e4tn/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-x_f5jys4/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-g3gfug52/overlay --compile --install-headers /tmp/pip-build-env-g3gfug52/overlay/include/python3.8/cffi Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-g3gfug52/overlay --no-warn-script-location --no-binary psycopg2 --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.0' Check the logs for full command output.
ERROR: Service 'django' failed to build: The command '/bin/sh -c pip install --no-cache-dir -r /requirements/production.txt     && rm -rf /requirements' returned a non-zero code: 1

compose / production / django / dockerfile:

FROM python:3.8-slim-buster

ENV PYTHONUNBUFFERED 1

RUN apt-get update \
  # dependencies for building Python packages
  && apt-get install -y build-essential \
  # psycopg2 dependencies
  && apt-get install -y libpq-dev \
  # Translations dependencies
  && apt-get install -y gettext \
  # cleaning up unused files
  && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
  && rm -rf /var/lib/apt/lists/*

RUN addgroup --system django \
    && adduser --system --ingroup django django

# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install --no-cache-dir -r /requirements/production.txt \
    && rm -rf /requirements

COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint
RUN chown django /entrypoint

COPY ./compose/production/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
RUN chown django /start
COPY --chown=django:django . /app

USER django

WORKDIR /app

ENTRYPOINT ["/entrypoint"]
django docker-compose alpine cookiecutter-django
1个回答
0
投票

是python docker容器3.8 slim-buster,应该具有libffi-dev installed

您仍然可以检查以下内容是否有帮助。通过向dockerfile添加其他行

&& apt-get install -y libffi-dev \
© www.soinside.com 2019 - 2024. All rights reserved.