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
|
||||
backend/qlockify-backend/
|
||||
frontend/qlockify-frontend/
|
||||
.env
|
||||
backend/logs/
|
||||
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_USER=app_user
|
||||
POSTGRES_PASSWORD=app_password
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_HOST=db
|
||||
POSTGRES_PORT=5432
|
||||
|
||||
# CORS / CSRF
|
||||
@@ -30,11 +30,11 @@ JWT_ALGORITHM=HS256
|
||||
|
||||
# Redis / Celery
|
||||
REDIS_URL=redis://redis:6379/0
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=
|
||||
CELERY_BROKER_URL=
|
||||
CELERY_RESULT_BACKEND=
|
||||
CELERY_BROKER_URL=redis://redis:6379/0
|
||||
CELERY_RESULT_BACKEND=redis://redis:6379/0
|
||||
|
||||
# Timzone / Language
|
||||
LANGUAGE_CODE=en-us
|
||||
|
||||
@@ -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/
|
||||
RUN pip install --no-cache-dir -r requirements/base.txt \
|
||||
&& pip install --no-cache-dir -r requirements/prod.txt
|
||||
|
||||
COPY qlockify-backend/ .
|
||||
|
||||
CMD ["gunicorn", "core.wsgi:application", "--bind", "0.0.0.0:8000"]
|
||||
COPY qlockify-backend/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/ .
|
||||
|
||||
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
|
||||
restart: always
|
||||
env_file:
|
||||
@@ -26,34 +24,38 @@ services:
|
||||
ports:
|
||||
- "127.0.0.1:6379:6379"
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
backend:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: qlockify-deployment/backend/Dockerfile
|
||||
restart: always
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
volumes:
|
||||
- static_data:/app/staticfiles
|
||||
- media_data:/app/mediafiles
|
||||
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
|
||||
redis:
|
||||
condition: service_started
|
||||
|
||||
celery:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
celery:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: qlockify-deployment/backend/Dockerfile
|
||||
restart: always
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
volumes:
|
||||
- media_data:/app/mediafiles
|
||||
command: celery -A core worker -l INFO
|
||||
command: celery -A config worker -l INFO
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
@@ -62,10 +64,10 @@ services:
|
||||
backend:
|
||||
condition: service_started
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
frontend:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: qlockify-deployment/frontend/Dockerfile
|
||||
restart: always
|
||||
env_file:
|
||||
- ./frontend/.env
|
||||
@@ -87,7 +89,7 @@ services:
|
||||
- backend
|
||||
- frontend
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
static_data:
|
||||
media_data:
|
||||
volumes:
|
||||
postgres_data:
|
||||
static_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
|
||||
|
||||
COPY qlockify-frontend/package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY qlockify-frontend/ .
|
||||
RUN npm run build
|
||||
COPY qlockify-frontend/package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY qlockify-frontend/ .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
|
||||
Reference in New Issue
Block a user