build(deployment): use local backend and frontend build contexts

This commit is contained in:
2026-04-25 17:27:10 +03:30
parent d3f14aeb78
commit 8b6f25e068
4 changed files with 40 additions and 37 deletions

View File

@@ -2,29 +2,32 @@
This repository is the deployment layer only. This repository is the deployment layer only.
It does not contain application source copies. Docker builds read directly from the sibling repositories: 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.
- `../qlockify-backend`
- `../qlockify-frontend`
## Local structure ## Local structure
The expected directory layout is: The expected deployment layout is:
```text ```text
Qlockify/ qlockify-deployment/
qlockify-backend/ backend/
qlockify-frontend/ frontend/
qlockify-deployment/ nginx/
postgres/
docker-compose.yml
``` ```
## Deployment flow ## Deployment flow
1. Configure deployment env files: 1. Put your application source into:
- `./backend`
- `./frontend`
2. Configure deployment env files:
- `./.env` - `./.env`
- `./backend/.env` - `./backend/.env`
- `./frontend/.env` - `./frontend/.env`
2. From `qlockify-deployment`, build and start the stack: 3. From `qlockify-deployment`, build and start the stack:
```powershell ```powershell
docker compose up --build docker compose up --build

View File

@@ -16,10 +16,10 @@ RUN apt-get update \
&& apt-get install -y gcc libpq-dev \ && apt-get install -y gcc libpq-dev \
&& rm -rf /var/lib/apt/lists/* && 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 \ RUN pip install --no-cache-dir -r requirements/base.txt \
&& pip install --no-cache-dir -r requirements/prod.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"] CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000"]

View File

@@ -1,5 +1,5 @@
services: services:
db: db:
image: postgres:18-alpine image: postgres:18-alpine
restart: always restart: always
env_file: env_file:
@@ -26,20 +26,20 @@ services:
backend: backend:
build: build:
context: .. context: ./backend
dockerfile: qlockify-deployment/backend/Dockerfile dockerfile: Dockerfile
restart: always restart: always
env_file: env_file:
- ./backend/.env - ./backend/.env
volumes: volumes:
- static_data:/app/staticfiles - static_data:/app/staticfiles
- media_data:/app/mediafiles - media_data:/app/mediafiles
command: > command: >
sh -c "python manage.py migrate && sh -c "python manage.py migrate &&
python manage.py collectstatic --noinput && python manage.py collectstatic --noinput &&
gunicorn config.wsgi:application --bind 0.0.0.0:8000" gunicorn config.wsgi:application --bind 0.0.0.0:8000"
expose: expose:
- "8000" - "8000"
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
@@ -48,14 +48,14 @@ services:
celery: celery:
build: build:
context: .. context: ./backend
dockerfile: qlockify-deployment/backend/Dockerfile dockerfile: Dockerfile
restart: always restart: always
env_file: env_file:
- ./backend/.env - ./backend/.env
volumes: volumes:
- media_data:/app/mediafiles - media_data:/app/mediafiles
command: celery -A config worker -l INFO command: celery -A config worker -l INFO
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
@@ -66,8 +66,8 @@ services:
frontend: frontend:
build: build:
context: .. context: ./frontend
dockerfile: qlockify-deployment/frontend/Dockerfile dockerfile: Dockerfile
restart: always restart: always
env_file: env_file:
- ./frontend/.env - ./frontend/.env
@@ -89,7 +89,7 @@ services:
- backend - backend
- frontend - frontend
volumes: volumes:
postgres_data: postgres_data:
static_data: static_data:
media_data: media_data:

View File

@@ -4,10 +4,10 @@ WORKDIR /app
RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ --global RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ --global
COPY qlockify-frontend/package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
COPY qlockify-frontend/ . COPY . .
RUN npm run build RUN npm run build
FROM nginx:alpine FROM nginx:alpine