对此感到很沮丧,几天来一直试图让它发挥作用。我请求帮助。
这是一个包含 Postgres、Celery 和 Docker 的 Django 项目。首先我尝试使用RabbitMQ,出现了与现在Redis相同的错误,然后我多次尝试后换成redis,错误仍然相同,所以我认为问题出在Celery上,而不是RabbitMQ/Redis上。
Dockerfile:
FROM python:3.8.5-alpine
ENV PYTHONUNBUFFERED 1
RUN apk update \
# psycopg2 dependencies
&& apk add --virtual build-deps gcc python3-dev musl-dev \
&& apk add postgresql-dev \
# Pillow dependencies
&& apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
# Translation dependencies
&& apk add gettext \
# CFFI dependencies
&& apk add libffi-dev py-cffi \
&& apk add --no-cache openssl-dev libffi-dev \
&& apk add --no-cache --virtual .pynacl_deps build-base python3-dev libffi-dev
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY . /app/
docker-compose.yml:
version: '3'
volumes:
local_postgres_data: {}
services:
postgres:
image: postgres
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- local_postgres_data:/var/lib/postgresql/data
env_file:
- ./.envs/.postgres
django: &django
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/app/
ports:
- "8000:8000"
depends_on:
- postgres
redis:
image: redis:6.0.8
celeryworker:
<<: *django
image: pyrty_celeryworker
depends_on:
- redis
- postgres
ports: []
command: celery -A pyrty worker -l INFO
celerybeat:
<<: *django
image: pyrty_celerybeat
depends_on:
- redis
- postgres
ports: []
command: celery -A pyrty beat -l INFO
慕码人2483693
相关分类