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
async def get_token_header(authorization: str = Header()) -> Tuple[int, str]:
if not authorization:
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):
return True
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

View File

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

View File

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

View File

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

View File

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