Skip to content

Commit 7cb05d5

Browse files
authored
Developement mode (#9)
* fix tests * pep8
1 parent 3f00245 commit 7cb05d5

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ __pycache__/
33
*.pyc
44
**/test/
55
/.coverage
6+
dev.py
7+
*.geojson

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111

1212
/cache/
1313
/.coverage
14+
*.geojson

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ FROM ${BASE_IMAGE} AS base
66
ENV PYTHONBUFFERED=1
77
ENV PYTHONDONTWRITEBYTECODE=1
88
ENV CACHE_DIR=/tmp/cache
9+
ENV DJANGO_SETTINGS_MODULE=osm_paths.settings
910

1011
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
1112

@@ -16,12 +17,8 @@ RUN mkdir /app
1617
WORKDIR /app
1718

1819
# Install the application dependencies
19-
COPY requirements.txt /app/
20-
COPY pyproject.toml /app/
21-
RUN uv pip install --system --no-cache-dir -r requirements.txt -U
22-
23-
# Copy the Django project to the container
24-
RUN --mount=type=bind,src=./osm_paths,dst=/app/osm_paths uv pip install --system --no-cache-dir .
20+
RUN --mount=type=bind,src=./requirements.txt,dst=/app/requirements.txt uv pip install --system --no-cache-dir -r requirements.txt -U
21+
RUN --mount=type=bind,src=./osm_paths,dst=/app/osm_paths --mount=type=bind,src=./pyproject.toml,dst=/app/pyproject.toml uv pip install --system --no-cache-dir .
2522

2623
# Expose the Django port
2724
EXPOSE 8000

osm_paths/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def main():
66
"""Run administrative tasks."""
7-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "osm_paths.settings")
7+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "osm_paths.settings.dev")
88
try:
99
from django.core.management import execute_from_command_line
1010
except ImportError as exc:

osm_paths/settings.py renamed to osm_paths/settings/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,16 @@
1414
from pathlib import Path
1515

1616
# Build paths inside the project like this: BASE_DIR / 'subdir'.
17-
BASE_DIR = Path(__file__).resolve().parent.parent
17+
BASE_DIR = Path(__file__).resolve().parent.parent.parent
1818

1919

2020
# Quick-start development settings - unsuitable for production
2121
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
2222

23-
# SECURITY WARNING: keep the secret key used in production secret!
24-
SECRET_KEY = "django-insecure-ta38laalyq-bgjh5-$ev%vy$v@h$e-^04cv9$vctnjr)9q#twf"
25-
2623
# SECURITY WARNING: don't run with debug turned on in production!
27-
DEBUG = True
24+
DEBUG = False
2825

29-
ALLOWED_HOSTS = []
26+
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "").split(",")
3027

3128
# Application definition
3229

@@ -71,8 +68,8 @@
7168

7269
# Internationalization
7370
# https://docs.djangoproject.com/en/5.1/topics/i18n/
74-
LANGUAGE_CODE = "en-us"
75-
TIME_ZONE = "UTC"
71+
LANGUAGE_CODE = os.getenv("LANGUAGE_CODE", "en-us")
72+
TIME_ZONE = os.getenv("TZ", "UTC")
7673
USE_I18N = True
7774
USE_TZ = True
7875

osm_paths/settings/dev.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from . import * # NOQA
2+
3+
DEBUG = True
4+
5+
# SECURITY WARNING: keep the secret key used in production secret!
6+
SECRET_KEY = "django-insecure-ta38laalyq-bgjh5-$ev%vy$v@h$e-^04cv9$vctnjr)9q#twf"
7+
ALLOWED_HOSTS = ["*"]

pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ build-backend = "hatchling.build"
44

55
[tool.hatch.build.targets.wheel]
66
packages = ["osm_paths",]
7-
8-
[tool.hatch.build.targets.sdist.force-include]
9-
"./osm_paths" = "osm_paths"
7+
exclude = [
8+
"**/tests",
9+
"**/dev.py",
10+
]
11+
[tool.hatch.build.targets.sdist]
12+
packages = ["osm_paths",]
13+
exclude = [
14+
"/osm_paths/download/tests",
15+
"/osm_paths/settings/dev.py",
16+
]
1017

1118
[project]
1219
version = "0.1.0"

0 commit comments

Comments
 (0)