Added celery as service
This commit is contained in:
parent
2dbe05782d
commit
683f6c1b98
5 changed files with 60 additions and 5 deletions
18
compose/dev/celery/Dockerfile
Normal file
18
compose/dev/celery/Dockerfile
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
FROM python:3.12-bookworm
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
|
build-essential \
|
||||||
|
libpq-dev \
|
||||||
|
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements/* /tmp/requirements/
|
||||||
|
RUN pip install --no-cache-dir --requirement /tmp/requirements/local.txt
|
||||||
|
|
||||||
|
COPY manage.py manage.py
|
||||||
|
COPY config config
|
||||||
|
COPY apps apps
|
||||||
|
|
||||||
|
CMD ["celery", "-A", "config", "worker", "-l", "info"]
|
||||||
|
|
@ -1,6 +1,19 @@
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
|
fyp-redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
container_name: fyp-redis
|
||||||
|
ports:
|
||||||
|
- "0.0.0.0:6379:6379"
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
web:
|
web:
|
||||||
build:
|
build:
|
||||||
context: ../..
|
context: ../..
|
||||||
|
|
@ -24,5 +37,27 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ../../:/app:cached
|
- ../../:/app:cached
|
||||||
- ../../build:/app/build
|
- ../../build:/app/build
|
||||||
|
environment:
|
||||||
|
DJANGO_CELERY_BROKER_URL: redis://fyp-redis:6379/0
|
||||||
|
DJANGO_SETTINGS_MODULE: config.settings
|
||||||
|
depends_on:
|
||||||
|
fyp-redis:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
celery:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: compose/dev/celery/Dockerfile
|
||||||
|
command: celery -A config worker -l info
|
||||||
|
volumes:
|
||||||
|
- ../../:/app:cached
|
||||||
|
- ${USERPROFILE}/.cache/gpt4all:/root/.cache/gpt4all:ro
|
||||||
|
environment:
|
||||||
|
DJANGO_CELERY_BROKER_URL: redis://fyp-redis:6379/0
|
||||||
|
DJANGO_SETTINGS_MODULE: config.settings
|
||||||
|
depends_on:
|
||||||
|
fyp-redis:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
redis_data:
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ FROM node:22-bullseye
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm ci
|
||||||
|
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
COPY index.html .
|
COPY index.html .
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ COPY tsconfig.* .
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM python:3.14.0-bookworm as python
|
FROM python:3.12-bookworm as python
|
||||||
|
|
||||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
build-essential \
|
build-essential \
|
||||||
|
|
@ -25,7 +25,9 @@ RUN pip install --no-cache-dir --requirement local.txt
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
COPY manage.py manage.py
|
||||||
|
COPY config config
|
||||||
|
COPY apps apps
|
||||||
|
|
||||||
COPY --from=node /app/build ./build
|
COPY --from=node /app/build ./build
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ set -o nounset
|
||||||
python manage.py makemigrations
|
python manage.py makemigrations
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
python manage.py collectstatic --noinput
|
python manage.py collectstatic --noinput
|
||||||
exec /usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:8000
|
exec /usr/local/bin/daphne -b 0.0.0.0 -p 8000 config.asgi:application
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue