admin管理员组

文章数量:1122846

I have a django app and I installed the module django-ckeditor. I can run the app with the command:

python manage.py runserver without any problems.

But after I build the docker container with the command:

docker-compose -f docker-compose-deploy.yml up

I get this errors:

 import_module("%s.%s" % (app_config.name, module_to_search))
web-1    |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
web-1    |     return _bootstrap._gcd_import(name[level:], package, level)
web-1    |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
web-1    |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
web-1    |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
web-1    |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
web-1    |   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
web-1    |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
web-1    |   File "/usr/src/app/DierenWelzijnAdmin/admin.py", line 17, in <module>
web-1    |     from ckeditor.widgets import CKEditorWidget
web-1    | ModuleNotFoundError: No module named 'ckeditor'
web-1    | [2024-11-21 15:50:43 +0000] [7] [INFO] Worker exiting (pid: 7)
web-1    | [2024-11-21 15:50:43 +0000] [1] [ERROR] Worker (pid:7) exited with code 3
web-1    | [2024-11-21 15:50:43 +0000] [1] [ERROR] Shutting down: Master
web-1    | [2024-11-21 15:50:43 +0000] [1] [ERROR] Reason: Worker failed to boot.

I added ckeditor in settings.py file:

INSTALLED_APPS = [
    
    'django_ckeditor_5'

I added ckeditor in requirements.txt file:


django-ckeditor-5==0.2.15

I added ckeditor in pip file:

[packages]
django-ckeditor-5==0.2.15
[dev-packages]

[requires]
python_version = "3.11"
python_full_version = "3.11.*"

urls.py file:

 path('ckeditor5/', include('django_ckeditor_5.urls')),

docker-compose-deploy.yml file:

services:
  web:
    image: crdierenwelzijn.azurecr.io/web1
    build:
      context: ./
      dockerfile: Dockerfile.prod
    restart: always

    command: gunicorn DierenWelzijn.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - static_volume:/usr/src/app/staticfiles
      - media_volume:/usr/src/app/media
    expose:
      - 8000
    env_file:
      - ./.env

  proxy:
    image: crdierenwelzijn.azurecr.io/proxy1
    build:
      context: ./proxy
    restart: always
    depends_on:
      - web
    ports:
      - 80:80
    volumes:
      - static_volume:/home/app/staticfiles
      - media_volume:/home/app/media

volumes:
  static_volume:
  media_volume:

dockerfile.prod:

# pull official base image
FROM python:3.9-alpine3.13

# ENV PATH="/scripts:${PATH}"

# set work directory
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /tmp/requirements.txt
COPY ./scripts /scripts

WORKDIR /usr/src/app
EXPOSE 8000


# install psycopg2 dependencies
ARG DEV=false
RUN python -m venv /py && \
    /py/bin/pip install --upgrade pip && \
    apk add --update --no-cache postgresql-client jpeg-dev && \
    apk add --update --no-cache --virtual .tmp-build-deps \
    build-base postgresql-dev musl-dev zlib zlib-dev linux-headers && \
    /py/bin/pip install -r /tmp/requirements.txt && \
    if [ $DEV = "true" ]; \
    then /py/bin/pip install -r /tmp/requirements.dev.txt ; \
    fi && \
    rm -rf /tmp && \
    apk del .tmp-build-deps && \
    adduser \
    --disabled-password \
    --no-create-home \
    django-user && \
    mkdir -p /vol/web/media && \
    mkdir -p /vol/web/static && \
    chown -R django-user:django-user /vol && \
    chmod -R 755 /vol && \
    chmod -R +x /scripts



ENV PATH="/scripts:/py/bin:$PATH"

COPY . .
# run entrypoint.sh

CMD ["runprod.sh"]

And I checked the installed django-ckeditor version with

pip show django-ckeditor-5
Name: django-ckeditor-5
Version: 0.2.15
Summary: CKEditor 5 for Django.

So I don't know how to resolve this error?

Question: How to build the docker container with the ckeditor module?

本文标签: pythonHow to run djangockeditor5 with docker containerStack Overflow