-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update template with Django 5 and PostreSQL 16
- Loading branch information
Noskov Alexey
committed
Apr 8, 2024
1 parent
a77ed3e
commit 613a14d
Showing
14 changed files
with
2,340 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,3 +125,6 @@ dmypy.json | |
|
||
# PyCharm | ||
.idea | ||
|
||
# Static files | ||
/static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
default_language_version: | ||
python: python3.9 | ||
python: python3.12 | ||
|
||
repos: | ||
- repo: local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
FROM python:3.9 | ||
FROM python:3.12-slim | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
|
||
COPY /scripts/wait-for-it.sh /wait-for-it.sh | ||
RUN chmod +x wait-for-it.sh | ||
|
||
COPY /scripts/start.sh /start.sh | ||
RUN chmod +x /start.sh | ||
|
||
COPY /scripts/start-dev.sh /start-dev.sh | ||
RUN chmod +x /start-dev.sh | ||
|
||
COPY poetry.lock pyproject.toml / | ||
RUN pip install poetry==1.1.6 \ | ||
RUN pip install poetry==1.8.2 \ | ||
&& poetry config virtualenvs.create false \ | ||
&& poetry install --no-dev --no-root | ||
|
||
WORKDIR /app | ||
COPY app docker-entrypoint.sh ./ | ||
|
||
CMD ["./docker-entrypoint.sh"] | ||
COPY app ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
.PHONY: static | ||
|
||
docker_compose_path = "docker-compose.yml" | ||
|
||
DC = docker-compose -f $(docker_compose_path) | ||
DC_RUN = $(DC) run --rm | ||
DC_RUN_MNG = $(DC_RUN) django python manage.py | ||
|
||
################################################################################################### | ||
## Build/run/stop/etc. ############################################################################ | ||
|
||
createsuperuser: | ||
$(DC_RUN_MNG) createsuperuser | ||
|
||
static: | ||
$(DC_RUN_MNG) collectstatic --no-input | ||
|
||
build: | ||
$(DC) build --no-cache | ||
make static | ||
|
||
up: | ||
$(DC) up -d --build | ||
|
||
down: | ||
$(DC) down | ||
|
||
restart: | ||
$(DC) restart | ||
|
||
################################################################################################### | ||
## Databases ###################################################################################### | ||
|
||
migrations: # produce migrations from code | ||
$(DC_RUN_MNG) makemigrations | ||
|
||
migrate: # apply db migrations | ||
$(DC_RUN_MNG) migrate | ||
|
||
################################################################################################### | ||
## Testing ######################################################################################## | ||
|
||
# Run tests locally. All pytest args can be specified using `pytest-args`: | ||
# $ make tests pytest-args='-k test_name' # Run specific test. | ||
# $ make tests pytest-args='--ff -x' # Run all tests. Stop if any fail. Rerun last failed if any. | ||
|
||
test: | ||
@echo 'Running tests with arguments: '$(pytest-args) | ||
$(DC_RUN) django poetry run pytest --ds=settings.test -v $(pytest-args) . | ||
|
||
test-coverage: | ||
@echo 'Running test coverage with arguments: '$(pytest-args) | ||
$(DC_RUN) django pytest --ds=settings.test --cov=. --cov-report=term-missing --cov-config=../pyproject.toml -c ../pyproject.toml . | ||
|
||
################################################################################################### | ||
## Code tools ##################################################################################### | ||
|
||
install-pre-commit: | ||
poetry run pre-commit install | ||
|
||
check: | ||
poetry run black --check backend | ||
poetry run isort --check backend | ||
|
||
format: | ||
poetry run black . | ||
poetry run isort . | ||
|
||
lint: | ||
poetry run black --check backend | ||
poetry run isort --check backend | ||
poetry run flake8 --inline-quotes '"' | ||
@# For some reason, mypy and pylint fails to resolve PYTHONPATH, set manually. | ||
PYTHONPATH=./app poetry run pylint app | ||
PYTHONPATH=./app poetry run mypy --namespace-packages --show-error-codes app --check-untyped-defs --ignore-missing-imports --show-traceback | ||
|
||
safety: | ||
poetry run safety check --policy-file=.safety-policy.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from settings.base import * | ||
|
||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = ["*"] | ||
|
||
EMAIL_HOST = 'localhost' | ||
EMAIL_PORT = '1025' | ||
|
||
SECRET_KEY = "test-a-valid-secret-key" # noqa: S105 | ||
|
||
PASSWORD_HASHERS = [ | ||
"django.contrib.auth.hashers.MD5PasswordHasher", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.