Skip to content

Commit 260ebda

Browse files
authored
Merge pull request #3 from hotosm/feature/add-custom-user-model
Creating a custom user model for extensibility
2 parents 75256c2 + 7e0820f commit 260ebda

15 files changed

+337
-50
lines changed

Dockerfile

+14-11
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RUN pip install --no-cache-dir --upgrade pip \
3535
poetry==1.7.1 poetry-plugin-export==1.6.0 \
3636
&& poetry config warnings.export false
3737
RUN poetry export --without dev --output requirements.txt
38-
RUN poetry export --only dev --output requirements-dev.txt
38+
RUN poetry export --with dev --output requirements-dev.txt
3939

4040

4141
# Define build stage (install deps)
@@ -102,28 +102,31 @@ USER wagtail
102102
ENTRYPOINT ["/container-entrypoint.sh"]
103103

104104

105+
# Define dev-deps stage (install requirements-dev)
106+
FROM runtime as dev-deps
107+
COPY --from=extract-deps --chown=wagtail \
108+
/opt/python/requirements-dev.txt /home/wagtail/
109+
RUN pip install --user --no-warn-script-location \
110+
--no-cache-dir -r /home/wagtail/requirements-dev.txt \
111+
&& rm -r /home/wagtail/requirements-dev.txt
112+
113+
105114
# Define test (ci) stage
106-
FROM runtime as test
115+
FROM dev-deps as test
107116
USER root
108117
ARG PYTHON_IMG_TAG
109-
COPY --from=extract-deps \
110-
/opt/python/requirements-dev.txt /opt/python/
111118
# Copy packages from user to root dirs (run ci as root)
112-
# && install dev dependencies (pytest)
113119
RUN mv /home/wagtail/.local/bin/* /usr/local/bin/ \
114-
&& mv /home/wagtail/.local/lib/python${PYTHON_IMG_TAG}/site-packages/* \
120+
&& cp -R /home/wagtail/.local/lib/python${PYTHON_IMG_TAG}/site-packages/* \
115121
/usr/local/lib/python${PYTHON_IMG_TAG}/site-packages/ \
116-
&& pip install --upgrade --no-warn-script-location \
117-
--no-cache-dir -r \
118-
/opt/python/requirements-dev.txt \
119-
&& rm -r /opt/python \
122+
&& rm -rf /home/wagtail/.local/ \
120123
# Pre-compile packages to .pyc (init speed gains)
121124
&& python -c "import compileall; compileall.compile_path(maxlevels=10, quiet=1)"
122125
CMD ["pytest"]
123126

124127

125128
# Define debug (development) stage
126-
FROM runtime as debug
129+
FROM dev-deps as debug
127130
# Add Healthcheck
128131
HEALTHCHECK --start-period=10s --interval=5s --retries=20 --timeout=5s \
129132
CMD curl --fail http://localhost:8000 || exit 1

Makefile

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build-dev build-prod test up-dev up-prod down-dev down-prod
22

3-
build-dev:
3+
build:
44
@docker compose -f docker-compose.dev.yml build
55
@docker compose -f docker-compose.dev.yml up -d
66

@@ -9,17 +9,15 @@ build-prod:
99
@docker compose -f docker-compose.prod.yml up -d
1010

1111
test:
12-
@docker build --target test -t myproject:test -f Dockerfile .
13-
@docker run --rm myproject:test
14-
@docker rmi myproject:test
12+
@docker compose -f docker-compose.dev.yml run --rm web pytest
1513

16-
up-dev:
14+
up:
1715
@docker compose -f docker-compose.dev.yml up -d
1816

1917
up-prod:
2018
@docker compose -f docker-compose.prod.yml up
2119

22-
down-dev:
20+
down:
2321
@docker compose -f docker-compose.dev.yml down
2422

2523
down-prod:

hot_osm/settings/base.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
INSTALLED_APPS = [
3434
"home",
3535
"search",
36+
"users",
3637
"wagtail.contrib.forms",
3738
"wagtail.contrib.redirects",
3839
"wagtail.embeds",
@@ -130,8 +131,6 @@
130131

131132
USE_I18N = True
132133

133-
USE_L10N = True
134-
135134
USE_TZ = True
136135

137136

@@ -150,7 +149,15 @@
150149
# ManifestStaticFilesStorage is recommended in production, to prevent outdated
151150
# JavaScript / CSS assets being served from cache (e.g. after a Wagtail upgrade).
152151
# See https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#manifeststaticfilesstorage
153-
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
152+
STORAGES = {
153+
"default": {
154+
"BACKEND": "django.core.files.storage.FileSystemStorage",
155+
"LOCATION": os.path.join(BASE_DIR, "media"),
156+
},
157+
"staticfiles": {
158+
"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
159+
},
160+
}
154161

155162
STATIC_ROOT = os.path.join(BASE_DIR, "static")
156163
STATIC_URL = "/static/"
@@ -174,3 +181,5 @@
174181
# Base URL to use when referring to full URLs within the Wagtail admin backend -
175182
# e.g. in notification emails. Don't include '/admin' or a trailing slash
176183
WAGTAILADMIN_BASE_URL = "http://example.com"
184+
185+
AUTH_USER_MODEL = "users.User"

poetry.lock

+117-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)