mirror of
https://github.com/more-tech4-magnum-opus/backend.git
synced 2024-11-10 14:36:34 +03:00
added docker
This commit is contained in:
parent
5c3b109f47
commit
7e6f815956
8
Dockerfile
Normal file
8
Dockerfile
Normal file
|
@ -0,0 +1,8 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM python:3
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
WORKDIR /code
|
||||
COPY requirements/* /code/
|
||||
RUN pip install -r prod.txt
|
||||
COPY . /code/
|
35
README.md
35
README.md
|
@ -1 +1,36 @@
|
|||
# backend
|
||||
|
||||
#### Веб-сервер, для обработки и хранения информации о пользователях и их операциях
|
||||
#
|
||||
Стек технологий:
|
||||
- Django, DRF, Channels
|
||||
- Celery
|
||||
- Postgresql
|
||||
- Swagger
|
||||
|
||||
## Сборка из исходного кода
|
||||
#### Установка зависимостей
|
||||
```shell
|
||||
$ python3 -m venv venv
|
||||
$ source venv/bin/activate
|
||||
$ cd app
|
||||
$ pip install -r reuirements/base.txt
|
||||
$ mv .env.example .env
|
||||
```
|
||||
|
||||
#### Подготовка бд
|
||||
```shell
|
||||
$ python3 manage.py makemigrations && python3 manage.py migrate users
|
||||
$ python3 manage.py migrate
|
||||
$ python manage.py loaddata departmens.json
|
||||
```
|
||||
|
||||
#### Запуск веб сервера
|
||||
```shell
|
||||
$ python3 manage.py runserver
|
||||
```
|
||||
|
||||
#### Запуск celery
|
||||
```shell
|
||||
$ celery -A conf worker --loglevel=INFO
|
||||
```
|
|
@ -3,12 +3,13 @@ from pathlib import Path
|
|||
import environ
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent
|
||||
ENV_DIR = ROOT_DIR.parent
|
||||
env = environ.Env()
|
||||
|
||||
READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=True)
|
||||
if READ_DOT_ENV_FILE:
|
||||
# OS environment variables take precedence over variables from .env
|
||||
env.read_env(str(ROOT_DIR / ".env"))
|
||||
env.read_env(str(ENV_DIR / ".env"))
|
||||
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
1
app/conf/settings/deploy.py
Normal file
1
app/conf/settings/deploy.py
Normal file
|
@ -0,0 +1 @@
|
|||
from .base import *
|
|
@ -29,7 +29,6 @@ class Event(models.Model):
|
|||
class EventAttendance(models.Model):
|
||||
event = models.ForeignKey(Event, related_name="people", on_delete=models.CASCADE)
|
||||
worker = models.ForeignKey(User, related_name="events", on_delete=models.CASCADE)
|
||||
token = models.CharField(blank=False, unique=True, max_length=128)
|
||||
attended = models.BooleanField(default=False)
|
||||
|
||||
@property
|
||||
|
|
|
@ -10,13 +10,8 @@ from .models import EventAttendance, Event
|
|||
@receiver(post_save, sender=EventAttendance)
|
||||
def create_attendance(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
token = generate_charset(25)
|
||||
while EventAttendance.objects.filter(token=token).exists():
|
||||
token = generate_charset(25)
|
||||
instance.token = token
|
||||
|
||||
instance.event.planning += 1
|
||||
instance.event.save(update_fields=["planning", "token"])
|
||||
instance.event.save(update_fields=["planning"])
|
||||
|
||||
|
||||
@receiver(post_save, sender=Event)
|
||||
|
|
25
docker-compose.yml
Normal file
25
docker-compose.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres
|
||||
volumes:
|
||||
- ./data/db:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=moretech
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=debug
|
||||
web:
|
||||
build: .
|
||||
command: python manage.py runserver 0.0.0.0:8000
|
||||
volumes:
|
||||
- .:/code
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- POSTGRES_NAME=postgres
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
depends_on:
|
||||
- db
|
||||
|
3
requirements/prod.txt
Normal file
3
requirements/prod.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
-r base.txt
|
||||
|
||||
gunicorn
|
Loading…
Reference in New Issue
Block a user