diff --git a/Dockerfile b/Dockerfile index 80e2fd6..a20bafd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,13 @@ COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules RUN apt-get update && \ apt-get upgrade -y && \ - apt-get install -y git + apt-get install -y git libatomic1 RUN ["pip", "install", "--no-cache-dir", "setuptools", "cookiecutter"] +# Verify node is working +RUN node -v && npm -v + RUN mkdir /cookiecutter WORKDIR /cookiecutter ENTRYPOINT ["cookiecutter"] diff --git a/README.md b/README.md index 672c855..b15f0fa 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,29 @@ ## Usage +### Option 1: From remote image (recommended) +Run this in whichever parent directory you'd like your project to live in. ```bash -# Build cookiecutter container (Only need to do once) +# Build cookiecutter container to make sure it's up to date docker build github.com/datamade/cookiecutter-django-app#main -t cookiecutter:latest # Generate a new project -docker run -it \ +docker run --rm -it \ --mount type=bind,source=$(pwd),target=/cookiecutter \ cookiecutter gh:datamade/cookiecutter-django-app ``` +### Option 2: From local files +Run this from the parent directory of this repo. Project will be built here. +```bash +# Build cookiecutter container to make sure it's up to date +docker build cookiecutter-django-app -t cookiecutter:latest + +# Generate a new project +docker run --rm -it \ + --mount type=bind,source=$(pwd),target=/cookiecutter \ + cookiecutter cookiecutter-django-app +``` + ### Notes In order to make sure tests pass easily on your new repo so you can publish to Heroku, make sure to: - add all of the cookiecutter output as one initial commit to `main` diff --git a/{{ cookiecutter.project_slug }}/django_module/settings.py b/{{ cookiecutter.project_slug }}/django_module/settings.py index 282dbba..22e55c0 100644 --- a/{{ cookiecutter.project_slug }}/django_module/settings.py +++ b/{{ cookiecutter.project_slug }}/django_module/settings.py @@ -51,6 +51,7 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django.contrib.postgres", {% if cookiecutter.install_wagtail %}"wagtail.contrib.forms", "wagtail.contrib.redirects", "wagtail.contrib.simple_translation", @@ -116,6 +117,7 @@ DATABASES = {} +{% if cookiecutter.install_postgis %} DATABASES["default"] = dj_database_url.parse( os.getenv( "DATABASE_URL", "postgis://postgres:postgres@postgres:5432/{{ cookiecutter.module_name }}" @@ -124,6 +126,16 @@ ssl_require=True if os.getenv("POSTGRES_REQUIRE_SSL") else False, engine="django.contrib.gis.db.backends.postgis", ) +{% else %} +DATABASES["default"] = dj_database_url.parse( + os.getenv( + "DATABASE_URL", "postgres://postgres:postgres@postgres:5432/{{ cookiecutter.module_name }}" + ), + conn_max_age=600, + ssl_require=True if os.getenv("POSTGRES_REQUIRE_SSL") else False, + engine="django.db.backends.postgresql", +) +{% endif %} # Caching # https://docs.djangoproject.com/en/stable/topics/cache/ diff --git a/{{ cookiecutter.project_slug }}/django_module/templates/base.html b/{{ cookiecutter.project_slug }}/django_module/templates/base.html index 0e1abf8..d9adf54 100644 --- a/{{ cookiecutter.project_slug }}/django_module/templates/base.html +++ b/{{ cookiecutter.project_slug }}/django_module/templates/base.html @@ -130,27 +130,6 @@ - - - - {% load render_bundle from webpack_loader %} {% render_bundle 'bootstrap' js %} diff --git a/{{ cookiecutter.project_slug }}/docker-compose.yml b/{{ cookiecutter.project_slug }}/docker-compose.yml index 8b2a81a..d149ef6 100644 --- a/{{ cookiecutter.project_slug }}/docker-compose.yml +++ b/{{ cookiecutter.project_slug }}/docker-compose.yml @@ -53,7 +53,7 @@ services: POSTGRES_PASSWORD: postgres POSTGRES_DB: {{ cookiecutter.module_name }} volumes: - - {{ cookiecutter.module_name }}-db-data:/var/lib/postgresql/data + - {{ cookiecutter.module_name }}-db-data:/var/lib/postgresql ports: - 32001:5432 diff --git a/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0001_initial.py b/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0001_initial.py index bee15dd..281cb79 100644 --- a/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0001_initial.py +++ b/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0001_initial.py @@ -5,7 +5,7 @@ class Migration(migrations.Migration): dependencies = [ - ("wagtailcore", "0040_page_draft_title"), + ("wagtailcore", "0095_groupsitepermission"), ] operations = [ diff --git a/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0002_examplemodel_examplemodeldetailpage.py b/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0002_examplemodel_examplemodeldetailpage.py index 5edba2a..b600048 100644 --- a/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0002_examplemodel_examplemodeldetailpage.py +++ b/{{ cookiecutter.project_slug }}/wagtail_module/migrations/0002_examplemodel_examplemodeldetailpage.py @@ -8,7 +8,6 @@ class Migration(migrations.Migration): dependencies = [ ("{{ cookiecutter.module_name }}", "0001_initial"), - ("wagtailcore", "0094_alter_page_locale"), ] operations = [ @@ -17,7 +16,7 @@ class Migration(migrations.Migration): fields=[ ( "id", - models.AutoField( + models.BigAutoField( auto_created=True, primary_key=True, serialize=False,