Added .env.example, fixed some bugs

This commit is contained in:
Даня Вакуленков 2024-12-17 16:48:36 +03:00
parent 3511d37fec
commit d16ab5fdc9
14 changed files with 48 additions and 14 deletions

4
.env.example/dev/back Normal file
View File

@ -0,0 +1,4 @@
DEBUG=1
SECRET_KEY=SECRET_KEY
ENVIRONMENT=docker
DJANGO_SETTINGS_MODULE=clicker.settings

1
.env.example/dev/batcher Normal file
View File

@ -0,0 +1 @@
HTTP_PORT=8080

View File

@ -0,0 +1,8 @@
POSTGRES_PASSWORD=postgres
POSTGRES_USER=postgres
POSTGRES_DB=postgres
POSTGRES_HOST=batcher-postgres
POSTGRES_PORT=5432
LANG=ru_RU.UTF-8
LANGUAGE=ru_RU.UTF-8
LC_ALL=ru_RU.UTF-8

3
.env.example/dev/bot Normal file
View File

@ -0,0 +1,3 @@
TG_TOKEN=token
BACKEND_URL=http://backend:8000
PROD=0

8
.env.example/dev/pg Normal file
View File

@ -0,0 +1,8 @@
POSTGRES_PASSWORD=postgres
POSTGRES_USER=postgres
POSTGRES_DB=postgres
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
LANG=ru_RU.UTF-8
LANGUAGE=ru_RU.UTF-8
LC_ALL=ru_RU.UTF-8

5
.env.example/dev/redis Normal file
View File

@ -0,0 +1,5 @@
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_USER=default
REDIS_PASSWORD=redis
REDIS_DB=0

4
.env.example/dev/rmq Normal file
View File

@ -0,0 +1,4 @@
RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672
RABBITMQ_DEFAULT_USER=rabbitmq
RABBITMQ_DEFAULT_PASS=rabbitmq

1
.env.example/dev/web Normal file
View File

@ -0,0 +1 @@
APP_URL=https://kyc-game.ru

View File

@ -8,7 +8,6 @@ from typing import Tuple
from .config import TG_TOKEN from .config import TG_TOKEN
async def get_token_header(authorization: str = Header()) -> Tuple[int, str]: async def get_token_header(authorization: str = Header()) -> Tuple[int, str]:
if not authorization: if not authorization:
raise HTTPException(status_code=403, detail='Unauthorized') raise HTTPException(status_code=403, detail='Unauthorized')

View File

@ -95,7 +95,7 @@ async def check_registration(r: redis.Redis, user_id: int, _token: str, backend_
if await _has_any_clicks(r, user_id): if await _has_any_clicks(r, user_id):
return True return True
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get(f'{backend_url}/api/v1/users/{user_id}', headers={'Authorization': _token}) as resp: async with session.get(f'{backend_url}/api/v1/users/{user_id}', headers={'Authorization': f'TelegramToken {_token}'}) as resp:
return resp.status == 200 return resp.status == 200

View File

@ -3,8 +3,7 @@ volumes:
batcher_db_data: {} batcher_db_data: {}
redis_data: {} redis_data: {}
backend_media: {} backend_media: {}
certbot_www: {} backend_static: {}
certbot_conf: {}
services: services:
backend: backend:
@ -12,6 +11,7 @@ services:
context: ./backend context: ./backend
volumes: volumes:
- backend_media:/app/media - backend_media:/app/media
- backend_static:/app/static
command: /app/scripts/gunicorn.sh command: /app/scripts/gunicorn.sh
restart: on-failure restart: on-failure
depends_on: depends_on:
@ -64,7 +64,7 @@ services:
depends_on: depends_on:
bot: *started-dependency bot: *started-dependency
volumes: volumes:
- ./backend/static/:/static/ - backend_static:/static/
restart: unless-stopped restart: unless-stopped
celery: celery:

View File

@ -3,6 +3,7 @@ volumes:
batcher_db_data: {} batcher_db_data: {}
redis_data: {} redis_data: {}
backend_media: {} backend_media: {}
backend_static: {}
services: services:
backend: backend:
@ -13,6 +14,7 @@ services:
rabbitmq: *healthy-dependency rabbitmq: *healthy-dependency
volumes: volumes:
- backend_media:/app/media - backend_media:/app/media
- backend_static:/app/static
command: /app/scripts/start.sh command: /app/scripts/start.sh
restart: on-failure restart: on-failure
env_file: &backend-env-files env_file: &backend-env-files

View File

@ -16,8 +16,6 @@ FROM nginx:stable
COPY nginx/nginx.conf /etc/nginx/nginx.conf COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY backend/static /static
COPY --from=build-deps /app/dist/ /dist/ COPY --from=build-deps /app/dist/ /dist/
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View File

@ -57,13 +57,12 @@ http {
} }
# batcher # batcher
location ~ ^/api/v1/batcher(/?.*) { location ^~ /api/v1/batcher {
rewrite ^(/api/v1)/batcher(/?.*)$ $1/$2 last; rewrite ^(/api/v1)/batcher/(.+)$ $1/$2 break;
proxy_pass http://batcher; proxy_pass http://batcher;
proxy_pass_header Authorization;
} }
location ^~ /api/internal { location ^~ /api/internal/ {
deny all; deny all;
} }
@ -73,14 +72,16 @@ http {
proxy_pass http://backend; proxy_pass http://backend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_cache_bypass $http_upgrade;
} }
# bot # bot
location ~ ^/bot { location ^~ /bot {
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_pass http://bot; proxy_pass http://bot;
} }
@ -107,7 +108,7 @@ http {
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
location ~ ^/rabbitmq/(.*) { location ^~ /rabbitmq {
rewrite ^/rabbitmq/(.*)$ /$1 break; rewrite ^/rabbitmq/(.*)$ /$1 break;
proxy_pass http://rabbitmq; proxy_pass http://rabbitmq;
proxy_buffering off; proxy_buffering off;