build(deployment): use sibling repos as docker build context
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
.env
|
.env
|
||||||
backend/qlockify-backend/
|
backend/logs/
|
||||||
frontend/qlockify-frontend/
|
backend/.pytest_cache/
|
||||||
|
|||||||
33
README.md
Normal file
33
README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Qlockify Deployment
|
||||||
|
|
||||||
|
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`
|
||||||
|
|
||||||
|
## Local structure
|
||||||
|
|
||||||
|
The expected directory layout is:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Qlockify/
|
||||||
|
qlockify-backend/
|
||||||
|
qlockify-frontend/
|
||||||
|
qlockify-deployment/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deployment flow
|
||||||
|
|
||||||
|
1. Configure deployment env files:
|
||||||
|
- `./.env`
|
||||||
|
- `./backend/.env`
|
||||||
|
- `./frontend/.env`
|
||||||
|
2. From `qlockify-deployment`, build and start the stack:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
|
||||||
|
The backend container runs database migrations and `collectstatic` on startup, then serves Django with Gunicorn using `config.wsgi:application`.
|
||||||
@@ -11,7 +11,7 @@ DJANGO_ALLOWED_HOSTS=
|
|||||||
POSTGRES_DB=app_db
|
POSTGRES_DB=app_db
|
||||||
POSTGRES_USER=app_user
|
POSTGRES_USER=app_user
|
||||||
POSTGRES_PASSWORD=app_password
|
POSTGRES_PASSWORD=app_password
|
||||||
POSTGRES_HOST=localhost
|
POSTGRES_HOST=db
|
||||||
POSTGRES_PORT=5432
|
POSTGRES_PORT=5432
|
||||||
|
|
||||||
# CORS / CSRF
|
# CORS / CSRF
|
||||||
@@ -30,11 +30,11 @@ JWT_ALGORITHM=HS256
|
|||||||
|
|
||||||
# Redis / Celery
|
# Redis / Celery
|
||||||
REDIS_URL=redis://redis:6379/0
|
REDIS_URL=redis://redis:6379/0
|
||||||
REDIS_HOST=127.0.0.1
|
REDIS_HOST=redis
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
REDIS_PASSWORD=
|
REDIS_PASSWORD=
|
||||||
CELERY_BROKER_URL=
|
CELERY_BROKER_URL=redis://redis:6379/0
|
||||||
CELERY_RESULT_BACKEND=
|
CELERY_RESULT_BACKEND=redis://redis:6379/0
|
||||||
|
|
||||||
# Timzone / Language
|
# Timzone / Language
|
||||||
LANGUAGE_CODE=en-us
|
LANGUAGE_CODE=en-us
|
||||||
|
|||||||
@@ -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 qlockify-backend/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 qlockify-backend/ .
|
||||||
|
|
||||||
CMD ["gunicorn", "core.wsgi:application", "--bind", "0.0.0.0:8000"]
|
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000"]
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
version: '3.8'
|
services:
|
||||||
|
db:
|
||||||
services:
|
|
||||||
db:
|
|
||||||
image: postgres:18-alpine
|
image: postgres:18-alpine
|
||||||
restart: always
|
restart: always
|
||||||
env_file:
|
env_file:
|
||||||
@@ -26,34 +24,38 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:6379:6379"
|
- "127.0.0.1:6379:6379"
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: ..
|
||||||
dockerfile: Dockerfile
|
dockerfile: qlockify-deployment/backend/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
|
||||||
expose:
|
command: >
|
||||||
- "8000"
|
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:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
redis:
|
redis:
|
||||||
condition: service_started
|
condition: service_started
|
||||||
|
|
||||||
celery:
|
celery:
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: ..
|
||||||
dockerfile: Dockerfile
|
dockerfile: qlockify-deployment/backend/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 core worker -l INFO
|
command: celery -A config worker -l INFO
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -62,10 +64,10 @@ services:
|
|||||||
backend:
|
backend:
|
||||||
condition: service_started
|
condition: service_started
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ..
|
||||||
dockerfile: Dockerfile
|
dockerfile: qlockify-deployment/frontend/Dockerfile
|
||||||
restart: always
|
restart: always
|
||||||
env_file:
|
env_file:
|
||||||
- ./frontend/.env
|
- ./frontend/.env
|
||||||
@@ -87,7 +89,7 @@ services:
|
|||||||
- backend
|
- backend
|
||||||
- frontend
|
- frontend
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
static_data:
|
static_data:
|
||||||
media_data:
|
media_data:
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
VITE_API_BASE_URL=http://localhost/api
|
VITE_API_BASE_URL=http://localhost/api
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ 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 qlockify-frontend/package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
COPY qlockify-frontend/ .
|
COPY qlockify-frontend/ .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user