mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-05 05:11:50 +02:00
dev-env setup
This commit is contained in:
parent
89e85f97f4
commit
0f43088dab
7 changed files with 72 additions and 7 deletions
5
.env.example
Normal file
5
.env.example
Normal file
|
@ -0,0 +1,5 @@
|
|||
POSTGRES_USER=
|
||||
POSTGRES_PASSWORD=
|
||||
POSTGRES_HOST=
|
||||
DB_PORT=
|
||||
POSTGRES_DB=
|
38
Makefile
Normal file
38
Makefile
Normal file
|
@ -0,0 +1,38 @@
|
|||
SHELL := /bin/bash
|
||||
|
||||
# PYTHON
|
||||
VENV_NAME := .venv
|
||||
PYTHON := $(VENV_NAME)/bin/python
|
||||
PIP := $(VENV_NAME)/bin/pip
|
||||
REQUIREMENTS := requirements-dev.txt
|
||||
|
||||
# Docker
|
||||
DOCKER_COMPOSE := docker-compose
|
||||
DOCKER_COMPOSE_FILE := docker-compose.yml
|
||||
DOCKER_DIRECTORY := dev_env
|
||||
|
||||
.PHONY: all venv install activate clean dev_env_start dev_env_stop
|
||||
|
||||
all: venv install activate
|
||||
|
||||
venv:
|
||||
python3 -m venv $(VENV_NAME)
|
||||
@echo "Activating virtual environment with 'source $(VENV_NAME)/bin/activate'. Run 'deactivate' to exit."
|
||||
|
||||
install: venv
|
||||
@source $(VENV_NAME)/bin/activate && $(PIP) install -r $(REQUIREMENTS)
|
||||
|
||||
clean:
|
||||
rm -rf $(VENV_NAME)
|
||||
|
||||
dev_env_start:
|
||||
if [ ! $(DOCKER_COMPOSE)]; then \
|
||||
echo "Docker Compose not installed. Please install Docker Compose."; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(DOCKER_COMPOSE) -f $(DOCKER_DIRECTORY)/$(DOCKER_COMPOSE_FILE) up -d
|
||||
@echo "Running migrations..."
|
||||
$(PYTHON) manage.py migrate
|
||||
|
||||
dev_env_stop:
|
||||
$(DOCKER_COMPOSE) -f $(DOCKER_DIRECTORY)/$(DOCKER_COMPOSE_FILE) down -v
|
13
dev_env/docker-compose.yml
Normal file
13
dev_env/docker-compose.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:13
|
||||
restart: always
|
||||
env_file:
|
||||
- ../.env
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- ./postgres-data:/var/lib/postgresql/data
|
||||
|
|
@ -3,6 +3,9 @@ from pathlib import Path
|
|||
|
||||
import sentry_sdk
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
BASE_URL = os.getenv("BASE_URL", "http://127.0.0.1:8000")
|
||||
|
@ -83,16 +86,16 @@ WSGI_APPLICATION = "la_chariotte.wsgi.application"
|
|||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": os.getenv("DB_NAME", "chariotte"),
|
||||
"NAME": os.getenv("POSTGRES_DB", "chariotte"),
|
||||
}
|
||||
}
|
||||
|
||||
if os.getenv("DB_USER"):
|
||||
DATABASES["default"]["USER"] = os.getenv("DB_USER")
|
||||
if os.getenv("DB_PASSWORD"):
|
||||
DATABASES["default"]["PASSWORD"] = os.getenv("DB_PASSWORD")
|
||||
if os.getenv("DB_HOST"):
|
||||
DATABASES["default"]["HOST"] = os.getenv("DB_HOST")
|
||||
if os.getenv("POSTGRES_USER"):
|
||||
DATABASES["default"]["USER"] = os.getenv("POSTGRES_USER")
|
||||
if os.getenv("POSTGRES_PASSWORD"):
|
||||
DATABASES["default"]["PASSWORD"] = os.getenv("POSTGRES_PASSWORD")
|
||||
if os.getenv("POSTGRES_HOST"):
|
||||
DATABASES["default"]["HOST"] = os.getenv("POSTGRES_HOST")
|
||||
if os.getenv("DB_PORT"):
|
||||
DATABASES["default"]["PORT"] = os.getenv("DB_PORT")
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ dependencies = [
|
|||
"html2text>=2020.1.16",
|
||||
"django-crispy-forms>=2.0,<3",
|
||||
"crispy-bulma>=0.11.0,<1",
|
||||
"python-dotenv==1.0.0"
|
||||
]
|
||||
|
||||
[tool.setuptools]
|
||||
|
|
|
@ -212,7 +212,10 @@ zipp==3.15.0
|
|||
# via importlib-metadata
|
||||
zopfli==0.2.2
|
||||
# via fonttools
|
||||
python-dotenv==1.0.0
|
||||
# via la-chariotte (pyproject.toml)
|
||||
|
||||
# The following packages are considered to be unsafe in a requirements file:
|
||||
# pip
|
||||
# setuptools
|
||||
|
||||
|
|
|
@ -137,3 +137,5 @@ xhtml2pdf==0.2.11
|
|||
# via la-chariotte (pyproject.toml)
|
||||
zopfli==0.2.2
|
||||
# via fonttools
|
||||
python-dotenv==1.0.0
|
||||
# via la-chariotte (pyproject.toml)
|
||||
|
|
Loading…
Reference in a new issue