diff --git a/compose/dev/celery/Dockerfile b/compose/dev/celery/Dockerfile index 2a56dae..aa0f7ba 100644 --- a/compose/dev/celery/Dockerfile +++ b/compose/dev/celery/Dockerfile @@ -6,13 +6,14 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* +ENV VIRTUAL_ENV=/venv \ + PATH=/venv/bin:$PATH + +RUN python -m venv /venv + 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 +COPY requirements/base.txt . +RUN pip install --no-cache-dir --requirement base.txt CMD ["celery", "-A", "config", "worker", "-l", "info"] diff --git a/compose/dev/docker-compose.yml b/compose/dev/docker-compose.yml index 749effc..ca47412 100644 --- a/compose/dev/docker-compose.yml +++ b/compose/dev/docker-compose.yml @@ -20,13 +20,17 @@ services: dockerfile: compose/dev/node/Dockerfile environment: NODE_ENV: development + CHOKIDAR_USEPOLLING: "true" + stdin_open: true ports: - "0.0.0.0:5173:5173" volumes: - - ../../src:/app/src - - ../../index.html:/app/index.html - - ../../vite.config.ts:/app/vite.config.ts - - ../../tsconfig.json:/app/tsconfig.json + - ../../src:/app/src:delegated + - ../../index.html:/app/index.html:delegated + - ../../vite.config.ts:/app/vite.config.ts:delegated + - ../../tsconfig.json:/app/tsconfig.json:delegated + - ../../build:/app/build:delegated + - /app/node_modules api: build: @@ -35,25 +39,27 @@ services: ports: - "0.0.0.0:8000:8000" volumes: - - ../../:/app:cached - - ../../build:/app/build + - ../../:/app + - venv:/venv environment: - DJANGO_CELERY_BROKER_URL: redis://fyp-redis:6379/0 + CELERY_BROKER_URL: redis://fyp-redis:6379/0 DJANGO_SETTINGS_MODULE: config.settings depends_on: fyp-redis: condition: service_healthy + web: + condition: service_started celery: build: context: ../.. dockerfile: compose/dev/celery/Dockerfile - command: celery -A config worker -l info volumes: - - ../../:/app:cached + - ../../:/app + - venv:/venv - ${USERPROFILE}/.cache/gpt4all:/root/.cache/gpt4all:ro environment: - DJANGO_CELERY_BROKER_URL: redis://fyp-redis:6379/0 + CELERY_BROKER_URL: redis://fyp-redis:6379/0 DJANGO_SETTINGS_MODULE: config.settings depends_on: fyp-redis: @@ -61,3 +67,4 @@ services: volumes: redis_data: + venv: diff --git a/compose/dev/node/Dockerfile b/compose/dev/node/Dockerfile index 0833b3a..29dab4d 100644 --- a/compose/dev/node/Dockerfile +++ b/compose/dev/node/Dockerfile @@ -3,11 +3,13 @@ FROM node:22-bullseye WORKDIR /app COPY package*.json ./ -RUN npm ci +RUN npm ci && npm cache clean --force COPY src ./src COPY index.html . COPY vite.config.* . COPY tsconfig.* . -CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] \ No newline at end of file +EXPOSE 5173 + +CMD ["sh", "-c", "npm run dev -- --host 0.0.0.0 & npm run build -- --watch"] \ No newline at end of file diff --git a/compose/dev/python/Dockerfile b/compose/dev/python/Dockerfile index d19733c..e41afb0 100644 --- a/compose/dev/python/Dockerfile +++ b/compose/dev/python/Dockerfile @@ -1,18 +1,4 @@ -FROM node:22-alpine AS node - -WORKDIR /app - -COPY package*.json ./ -RUN npm ci - -COPY src ./src -COPY index.html . -COPY vite.config.* . -COPY tsconfig.* . - -RUN npm run build - -FROM python:3.12-bookworm as python +FROM python:3.12-bookworm RUN apt-get update && apt-get install --no-install-recommends -y \ build-essential \ @@ -20,19 +6,14 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* -COPY requirements/* . -RUN pip install --no-cache-dir --requirement local.txt +ENV VIRTUAL_ENV=/venv \ + PATH=/venv/bin:$PATH + +RUN python -m venv /venv WORKDIR /app -COPY manage.py manage.py -COPY config config -COPY apps apps +COPY requirements/base.txt . +RUN pip install --no-cache-dir --requirement base.txt -COPY --from=node /app/build ./build - -COPY ./compose/prod/start /start -RUN sed -i 's/\r$//g' /start -RUN chmod +x /start - -ENTRYPOINT ["/start"] \ No newline at end of file +CMD ["daphne", "-b", "0.0.0.0", "-p", "8000", "config.asgi:application"] \ No newline at end of file diff --git a/compose/prod/Dockerfile b/compose/prod/Dockerfile index 46d8834..74532df 100644 --- a/compose/prod/Dockerfile +++ b/compose/prod/Dockerfile @@ -14,7 +14,7 @@ COPY index.html . RUN npm run build -FROM python:3.14.0-slim as python +FROM python:3.12.0-slim AS python LABEL org.opencontainers.image.title="Dynavera - An Agentic Approach to Domain-Specific Trainers" LABEL org.opencontainers.image.source="https://git.cs.bham.ac.uk/projects-2025-26/vxn217" diff --git a/requirements/base.txt b/requirements/base.txt index 818ac0e..4304f34 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,6 +1,7 @@ asgiref==3.10.0 celery==5.6.0 django==5.2.8 +django-cors-headers==4.3.1 djangorestframework==3.16.1 channels[daphne]==4.3.0 channels-redis==4.1.0