Skip to content

Commit eec4eec

Browse files
committed
Use local override
1 parent fa7e242 commit eec4eec

7 files changed

Lines changed: 187 additions & 148 deletions

File tree

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44
__pycache__/
55
*.py[cod]
66
.venv/
7-
/compose.local.yml
8-
/docker-compose.override.yml
9-
/compose.override.yml

Makefile

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,66 @@
1-
# Makefile at repo-root
1+
SHELL := /usr/bin/env bash
2+
.ONESHELL:
3+
.DEFAULT_GOAL := help
4+
5+
# ==== Paths ====
6+
COMPOSE_BASE := infra/compose/compose.yml
7+
COMPOSE_LOCAL := infra/compose/compose.local.yml
8+
COMPOSE_DEV := infra/compose/stack.dev.yml
9+
COMPOSE_PROD := infra/compose/stack.prod.yml
10+
TRAEFIK_STACK := infra/compose/stack.traefik.yml
11+
12+
# ==== Envs ====
13+
ENV_FILE ?= .env
14+
15+
# ==== Helpers ====
16+
define source_env
17+
set -euo pipefail; \
18+
if [[ -f $(1) ]]; then \
19+
set -a; source $(1); set +a; \
20+
else \
21+
echo "ENV file $(1) not found"; exit 1; \
22+
fi
23+
endef
24+
25+
# ==== Help ====
26+
help: ## Показать цели Makefile
27+
@grep -E '^[a-zA-Z0-9_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
228

329
# Export all variables from .env file
430
ifneq (,$(wildcard ./.env))
531
include .env
632
export
733
endif
834

9-
up: ## Запустить весь стек (production mode - stable)
10-
docker-compose --env-file .env -f infra/compose/compose.yml up -d
35+
# ==== Commands ====
1136

12-
up-dev: ## Запустить весь стек (dev mode with volume mounts)
37+
up:
1338
docker compose \
14-
-f infra/compose/compose.yml \
15-
-f infra/compose/compose.dev.yml \
16-
-f compose.local.yml \
39+
--env-file $(ENV_FILE) \
40+
-f $(COMPOSE_BASE) \
41+
-f $(COMPOSE_PROD) \
1742
up -d
1843

44+
up-dev:
45+
docker compose \
46+
--env-file $(ENV_FILE) \
47+
-f $(COMPOSE_BASE) \
48+
-f $(COMPOSE_DEV) \
49+
up -d
50+
51+
up-local:
52+
docker compose \
53+
--env-file $(ENV_FILE) \
54+
-f $(COMPOSE_BASE) \
55+
-f $(COMPOSE_LOCAL) \
56+
up -d
57+
58+
deploy-dev:
59+
. $(ENV_FILE); docker stack deploy \
60+
-c $(COMPOSE_BASE) \
61+
-c $(COMPOSE_DEV) \
62+
--with-registry-auth app-dev
63+
1964
build: ## Пересобрать контейнеры (production)
2065
docker-compose --env-file .env -f infra/compose/compose.yml build
2166

compose.local.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

infra/compose/compose.local.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
volumes:
2+
mongo_data: {}
3+
pgdata: {}
4+
redis_data: {}
5+
app_data: {}
6+
logs_data: {}
7+
node_modules_cache: {}
8+
9+
services:
10+
api:
11+
build:
12+
context: ../backend
13+
command: [ "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload" ]
14+
env_file: ../../.env
15+
volumes:
16+
- ../backend:/app
17+
ports:
18+
- "8000:8000"
19+
depends_on:
20+
- mongo
21+
- postgres
22+
- redis
23+
24+
worker:
25+
build:
26+
context: ../backend
27+
command: [ "celery", "-A", "app.tasks.celery_app", "worker", "--concurrency=2", "--loglevel=INFO" ]
28+
env_file: ../../.env
29+
volumes:
30+
- ../backend:/app
31+
depends_on:
32+
- mongo
33+
- postgres
34+
- redis
35+
36+
frontend:
37+
build:
38+
context: ../frontend
39+
command: [ "npm", "run", "dev" ]
40+
environment:
41+
ENV: local
42+
NEXT_PUBLIC_API_URL: ${API_URL}
43+
SENTRY_DSN:
44+
volumes:
45+
- ../frontend:/app
46+
ports:
47+
- "3000:3000"
48+
depends_on:
49+
- api
50+
51+
mongo:
52+
image: mongo:8.0
53+
environment:
54+
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER}
55+
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASS}
56+
MONGO_INITDB_DATABASE: ${MONGO_DB}
57+
volumes:
58+
- mongo_data:/data/db
59+
networks: [ app-net ]
60+
ports:
61+
- "27017:27017"
62+
63+
postgres:
64+
image: postgres:17.5
65+
environment:
66+
POSTGRES_USER: ${PG_USER}
67+
POSTGRES_PASSWORD: ${PG_PASS}
68+
POSTGRES_DB: ${PG_DB}
69+
volumes:
70+
- pgdata:/var/lib/postgresql/data
71+
networks: [ app-net ]
72+
ports:
73+
- "5432:5432"
74+
# healthcheck:
75+
# test: [ "CMD-SHELL", "pg_isready -U user -d app" ]
76+
# interval: 5s
77+
# timeout: 5s
78+
# retries: 10
79+
80+
redis:
81+
image: redis:8.2-alpine
82+
command: [ "redis-server", "--appendonly", "no" ]
83+
volumes:
84+
- redis_data:/data
85+
networks: [ app-net ]
86+
ports:
87+
- "6379:6379"
88+
# healthcheck:
89+
# test: [ "CMD", "redis-cli", "-a", "redispass", "ping" ]
90+
# interval: 5s
91+
# timeout: 3s
92+
# retries: 10

infra/compose/compose.override.example.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

infra/compose/compose.yml

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,48 @@
1+
networks:
2+
app-net: {}
3+
14
services:
2-
backend:
3-
build:
4-
context: ../../backend
5-
env_file: .env
6-
volumes:
7-
- app_data:/app/data
8-
- logs_data:/app/logs
9-
ports:
10-
- "8000:8000"
11-
depends_on:
12-
- mongo
13-
- redis
5+
api:
6+
image: ${REGISTRY:-local}/${PROJECT_SLUG:-app}/api:${TAG:-local}
7+
env_file: ../../.env
8+
networks: [ app-net ]
9+
expose: [ "8000" ]
10+
deploy:
11+
restart_policy: { condition: on-failure }
1412

15-
frontend:
16-
build:
17-
context: ../../frontend
18-
env_file: .env
19-
environment:
20-
- NEXT_PUBLIC_API_URL=http://localhost:8000/v1
21-
volumes:
22-
- node_modules_cache:/app/node_modules
23-
ports:
24-
- "3000:3000"
25-
depends_on:
26-
- backend
13+
worker:
14+
image: ${REGISTRY:-local}/${PROJECT_SLUG:-app}/api:${TAG:-local}
15+
command: [ "celery", "-A", "app.tasks.celery_app", "worker", "-Q", "high,default,low", "--concurrency=4", "--loglevel=INFO", "-O", "fair" ]
16+
env_file: ../../.env
17+
networks: [ app-net ]
18+
deploy:
19+
restart_policy: { condition: on-failure }
20+
replicas: 2
2721

28-
mongo:
29-
image: mongo:8.0
30-
volumes:
31-
- mongo_data:/data/db
32-
environment:
33-
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USER}
34-
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASS}
35-
- MONGO_INITDB_DATABASE=${MONGO_DBNAME}
36-
ports:
37-
- "27017:27017"
22+
scheduler:
23+
image: ${REGISTRY:-local}/${PROJECT_SLUG:-app}/api:${TAG:-local}
24+
command: [ "celery", "-A", "app.tasks.celery_app", "beat", "--scheduler", "redbeat.RedBeatScheduler" ]
25+
env_file: ../../.env
26+
networks: [ app-net ]
27+
deploy:
28+
restart_policy: { condition: on-failure }
3829

39-
redis:
40-
image: redis:8.2
41-
volumes:
42-
- redis_data:/data
43-
ports:
44-
- "6379:6379"
30+
# daemon:
31+
# image: ${REGISTRY:-local}/${PROJECT_SLUG:-app}/api:${TAG:-local}
32+
# command: [ "python", "-m", "app.services.realtime_poller" ]
33+
# env_file: ../../.env
34+
# networks: [ app-net ]
35+
# deploy:
36+
# restart_policy: { condition: on-failure }
37+
# replicas: 1
4538

46-
volumes:
47-
mongo_data:
48-
redis_data:
49-
app_data:
50-
logs_data:
51-
node_modules_cache:
39+
frontend:
40+
image: ${REGISTRY:-local}/${PROJECT_SLUG:-app}/web:${TAG:-local}
41+
environment:
42+
ENV: ${ENV}
43+
NEXT_PUBLIC_API_URL: ${API_URL}
44+
SENTRY_DSN: ${SENTRY_DSN_FRONT:-}
45+
networks: [ app-net ]
46+
expose: [ "3000" ]
47+
deploy:
48+
restart_policy: { condition: on-failure }

infra/compose/stack.traefik.yaml

Whitespace-only changes.

0 commit comments

Comments
 (0)