From 8b6f25e068c702af04d9c80c83e9e0838715a9de Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Sat, 25 Apr 2026 17:27:10 +0330 Subject: [PATCH] build(deployment): use local backend and frontend build contexts --- README.md | 25 ++++++++++++++----------- backend/Dockerfile | 4 ++-- docker-compose.yml | 44 ++++++++++++++++++++++---------------------- frontend/Dockerfile | 4 ++-- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 029b579..0414371 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,32 @@ This repository is the deployment layer only. -It does not contain application source copies. Docker builds read directly from the sibling repositories: - -- `../qlockify-backend` -- `../qlockify-frontend` +Docker builds read from the local `./backend` and `./frontend` directories inside this repository. +Those directories are expected to contain the backend and frontend application source before you build for deployment. ## Local structure -The expected directory layout is: +The expected deployment layout is: ```text -Qlockify/ - qlockify-backend/ - qlockify-frontend/ - qlockify-deployment/ +qlockify-deployment/ + backend/ + frontend/ + nginx/ + postgres/ + docker-compose.yml ``` ## Deployment flow -1. Configure deployment env files: +1. Put your application source into: + - `./backend` + - `./frontend` +2. Configure deployment env files: - `./.env` - `./backend/.env` - `./frontend/.env` -2. From `qlockify-deployment`, build and start the stack: +3. From `qlockify-deployment`, build and start the stack: ```powershell docker compose up --build diff --git a/backend/Dockerfile b/backend/Dockerfile index 9948a8c..45f9d2d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -16,10 +16,10 @@ RUN apt-get update \ && apt-get install -y gcc libpq-dev \ && rm -rf /var/lib/apt/lists/* -COPY qlockify-backend/requirements/ /app/requirements/ +COPY requirements/ /app/requirements/ RUN pip install --no-cache-dir -r requirements/base.txt \ && pip install --no-cache-dir -r requirements/prod.txt -COPY qlockify-backend/ . +COPY . . CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000"] diff --git a/docker-compose.yml b/docker-compose.yml index c817788..0d7fcdb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ -services: - db: +services: + db: image: postgres:18-alpine restart: always env_file: @@ -26,20 +26,20 @@ services: backend: build: - context: .. - dockerfile: qlockify-deployment/backend/Dockerfile + context: ./backend + dockerfile: Dockerfile restart: always env_file: - ./backend/.env - volumes: - - static_data:/app/staticfiles - - media_data:/app/mediafiles - command: > - sh -c "python manage.py migrate && - python manage.py collectstatic --noinput && - gunicorn config.wsgi:application --bind 0.0.0.0:8000" - expose: - - "8000" + volumes: + - static_data:/app/staticfiles + - media_data:/app/mediafiles + command: > + sh -c "python manage.py migrate && + python manage.py collectstatic --noinput && + gunicorn config.wsgi:application --bind 0.0.0.0:8000" + expose: + - "8000" depends_on: db: condition: service_healthy @@ -48,14 +48,14 @@ services: celery: build: - context: .. - dockerfile: qlockify-deployment/backend/Dockerfile + context: ./backend + dockerfile: Dockerfile restart: always env_file: - ./backend/.env volumes: - media_data:/app/mediafiles - command: celery -A config worker -l INFO + command: celery -A config worker -l INFO depends_on: db: condition: service_healthy @@ -66,8 +66,8 @@ services: frontend: build: - context: .. - dockerfile: qlockify-deployment/frontend/Dockerfile + context: ./frontend + dockerfile: Dockerfile restart: always env_file: - ./frontend/.env @@ -89,7 +89,7 @@ services: - backend - frontend -volumes: - postgres_data: - static_data: - media_data: +volumes: + postgres_data: + static_data: + media_data: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 7d9aa5e..276fe81 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -4,10 +4,10 @@ WORKDIR /app RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ --global -COPY qlockify-frontend/package*.json ./ +COPY package*.json ./ RUN npm install -COPY qlockify-frontend/ . +COPY . . RUN npm run build FROM nginx:alpine