Skip to content

Commit

Permalink
create postgres local instance + change make 'run-db'
Browse files Browse the repository at this point in the history
  • Loading branch information
blizard-sis committed Dec 18, 2023
1 parent 15427c4 commit bd0fe32
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 45 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MANAGE_DIR := $(PROJECT_DIR)/adaptive_hockey_federation/manage.py
DJANGO_DIR := $(PROJECT_DIR)/adaptive_hockey_federation
POETRY_RUN := poetry run python
DJANGO_RUN := $(POETRY_RUN) $(MANAGE_DIR)
COMPOSE_DEV_RUN := docker-compose -f $(PROJECT_DIR)/adaptive_hockey_federation/infra/dev/docker-compose.dev.yamlup -d
COMPOSE_DEV_RUN := docker-compose -f $(PROJECT_DIR)/infra/dev/docker-compose.dev.yaml up -d
SHELL_GREEN = \033[32m
SHELL_YELLOW = \033[33m
SHELL_NC := \e[0m
Expand All @@ -22,6 +22,7 @@ help:
@echo " collectstatic - $(SHELL_GREEN)Команда для сбора статики.$(SHELL_NC)"
@echo " migrate - $(SHELL_GREEN)Команда для применения к базе данных готовых миграций.$(SHELL_NC)"
@echo " createsuperuser - $(SHELL_GREEN)Команда для создания супер-юзера.$(SHELL_NC)"
@echo " run-d - $(SHELL_GREEN)Команда для локального запуска контейнера postgres.$(SHELL_NC)"
@echo " run - $(SHELL_GREEN)Команда для локального запуска проекта.$(SHELL_NC)"
@echo " fill-db - $(SHELL_GREEN)Команда для заполнения базы данных с помощью парсера.$(SHELL_NC)"
@echo " pytest - $(SHELL_GREEN)Команда для прогона юнит тестов pytest.$(SHELL_NC)"
Expand Down Expand Up @@ -55,9 +56,14 @@ createsuperuser:
cd $(PROJECT_DIR) && $(DJANGO_RUN) createsuperuser


# Локальный запуск контейнера postgres.
run-db:
cd $(PROJECT_DIR) && $(COMPOSE_DEV_RUN)


# Локальный запуск сервера разработки.
run:
cd $(PROJECT_DIR) && $(COMPOSE_DEV_RUN) && $(DJANGO_RUN) runserver
cd $(PROJECT_DIR) && $(DJANGO_RUN) runserver


# Заполнение базы данных с помощью парсера.
Expand Down
13 changes: 10 additions & 3 deletions adaptive_hockey_federation/core/config/dev_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
from dotenv import load_dotenv

from pathlib import Path

load_dotenv()

# import environ

BASE_DIR = Path(__file__).resolve().parent.parent.parent
Expand Down Expand Up @@ -63,9 +67,12 @@

DATABASES = {
'default': {
# 'ENGINE': env('ENGINE'),
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': os.getenv('DB_ENGINE', default='django.db.backends.postgresql'),
'NAME': os.getenv('POSTGRES_DB'),
'USER': os.getenv('POSTGRES_USER'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT')
}
}

Expand Down
Loading

0 comments on commit bd0fe32

Please sign in to comment.