我正在尝试使用
django
运行 docker
应用程序 .. 当我尝试 docker-compose up --build
: 时,它给了我这个错误
water_maps | File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
water_maps | File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
water_maps | File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
water_maps | File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
water_maps | File "<frozen importlib._bootstrap_external>", line 995, in exec_module
water_maps | File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
water_maps | File "/var/www/html/demo_app/water_maps/__init__.py", line 4, in <module>
water_maps | from celery import Celery
water_maps | File "/usr/local/lib/python3.12/dist-packages/celery/__init__.py", line 17, in <module>
water_maps | from . import local # noqa
water_maps | ^^^^^^^^^^^^^^^^^^^
water_maps | File "/usr/local/lib/python3.12/dist-packages/celery/local.py", line 17, in <module>
water_maps | from .five import PY3, bytes_if_py2, items, string, string_t
water_maps | File "/usr/local/lib/python3.12/dist-packages/celery/five.py", line 7, in <module>
water_maps | import vine.five
water_maps | File "/usr/local/lib/python3.12/dist-packages/vine/__init__.py", line 8, in <module>
water_maps | from .abstract import Thenable
water_maps | File "/usr/local/lib/python3.12/dist-packages/vine/abstract.py", line 6, in <module>
water_maps | from .five import with_metaclass, Callable
water_maps | File "/usr/local/lib/python3.12/dist-packages/vine/five.py", line 364, in <module>
water_maps | from inspect import formatargspec, getargspec as _getargspec # noqa
water_maps | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
water_maps | ImportError: cannot import name 'formatargspec' from 'inspect' (/usr/lib/python3.12/inspect.py). Did you mean: 'formatargvalues'?
这是我的
Dockerfile
的样子 :
FROM ubuntu
RUN apt-get update
# Avoid tzdata infinite waiting bug
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Africa/Cairo
RUN apt clean
RUN apt-get update
RUN apt-get install -y apt-utils vim curl apache2 apache2-utils git
RUN apt-get -y install python3 libapache2-mod-wsgi-py3
RUN apt -y install certbot python3-certbot-apache
RUN ln /usr/bin/python3 /usr/bin/python
RUN apt-get -y install python3-pip
RUN apt -y install software-properties-common
RUN add-apt-repository universe
RUN apt update
#Add sf to avoid ln: failed to create hard link '/usr/bin/pip': File exists
RUN ln -sf /usr/bin/pip3 /usr/bin/pip
RUN pip install --upgrade pip --break-system-packages
RUN pip install django ptvsd --break-system-packages
RUN pip uninstall web3.py --break-system-packages
RUN pip install git+https://github.com/ethereum/web3.py.git --break-system-packages
RUN apt install wait-for-it
RUN apt-get -y install gettext
RUN apt-get -y install poppler-utils
RUN apt-get -y install redis-server
RUN a2enmod headers
RUN service apache2 restart
COPY www/demo_app/water_maps/requirements.txt requirements.txt
RUN pip install -r requirements.txt --break-system-packages
ADD ./demo_site.conf /etc/apache2/sites-available/000-default.conf
EXPOSE 80 5432
WORKDIR /var/www/html/demo_app
#CMD ["apache2ctl", "-D", "FOREGROUND"]
#CMD ["python", "manage.py", "migrate", "--no-input"]
这是我的
docker-compose.yaml
文件的样子:
version: "2"
services:
db:
image: postgres:14
restart: always
volumes:
- ./data/db:/var/lib/postgresql/data
- ./www/:/var/www/html
- ./www/demo_app/kml_files:/var/www/html/demo_app/kml_files
- ./www/demo_app/temp_kml_file:/var/www/html/demo_app/temp_kml_file
- ./www/demo_app/upload:/var/www/html/demo_app/upload
- ./data/log:/var/log/apache2
ports:
- '5432:5432'
environment:
- POSTGRES_DB=database_innvoentiq
- POSTGRES_USER=database_user_innvoentiq
- POSTGRES_PASSWORD=Yahoo000@
django-apache2:
build: .
container_name: water_maps
restart: always
environment:
- POSTGRES_DB=database_innvoentiq
- POSTGRES_USER=database_user_innvoentiq
- POSTGRES_PASSWORD=Yahoo000@
ports:
- 6000:80
- 6001:443
# - 80:80
# - 443:443
volumes:
- ./www/:/var/www/html
- ./www/demo_app/kml_files:/var/www/html/demo_app/kml_files
- ./www/demo_app/temp_kml_file:/var/www/html/demo_app/temp_kml_file
- ./www/demo_app/upload:/var/www/html/demo_app/upload
- ./data/log:/var/log/apache2
# - ./data/config/etc/apache2:/etc/apache2
# command: sh -c 'python manage.py migrate && python manage.py loaddata the_db.json '
command: sh -c 'wait-for-it db:5432 -- python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --noinput && python manage.py compilemessages && apache2ctl -D FOREGROUND'
# command: sh -c 'wait-for-it db:5432 -- python manage.py migrate && python manage.py loaddata last.json && apache2ctl -D FOREGROUND'
depends_on:
- db
inspect.formatargspec
最后在 Python 3.10 中可用,因为自 Python 3.5 以来,根据其文档,它被标记为弃用,并且根据 Python 3.11 的发行说明,它被标记为 removed。我要指出的是,自 5.0.0 版本发布以来,我看不到当前版本的 vine 实际上利用了这一点,按照 changelog。
您将需要更新该构建的依赖项。