Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wagtail DB persistent #996

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- GET Workspace [Layers](doc/rest.md#get-workspace-layers)/[Maps](doc/rest.md#get-workspace-maps)
- GET [Layers](doc/rest.md#get-layers)/[Maps](doc/rest.md#get-maps)/[Publications](doc/rest.md#get-publications)
- [#165](https://github.com/LayerManager/layman/issues/165) Name of [users](doc/models.md#username) and [public workspaces](doc/models.md#public-workspace) are from now on restricted to a maximum length of 59 characters.
- [941](https://github.com/LayerManager/layman/issues/941) Wagtail database is now persistent when restarting Layman or Wagtail.
- All changes from [v1.22.1](#v1221), [v1.22.2](#v1222) and [v1.22.3](#v1223).
- [#960](https://github.com/LayerManager/layman/issues/960) Handle WMS requests with HTTP error more efficiently in timgen.
- [#962](https://github.com/LayerManager/layman/issues/962) Make values of `layman_metadata.publication_status` and `status` key(s) more consistent in responses of PATCH Workspace [Layer](doc/rest.md#patch-workspace-layer)/[Map](doc/rest.md#patch-workspace-map) and GET Workspace [Layer](doc/rest.md#get-workspace-layer)/[Map](doc/rest.md#get-workspace-map).
Expand Down
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ start-demo-only:
docker compose -f docker-compose.deps.demo.yml -f docker-compose.demo.yml up -d --force-recreate --no-deps layman celery_worker flower timgen layman_client nginx

start-demo-full-with-optional-deps:
mkdir -p layman_data deps/qgis/data
mkdir -p layman_data deps/qgis/data deps/wagtail/data
docker compose -f docker-compose.deps.demo.yml -f docker-compose.demo.yml build layman layman_client timgen
docker compose -f docker-compose.deps.demo.yml -f docker-compose.demo.yml up -d postgresql
docker compose -f docker-compose.deps.demo.yml -f docker-compose.demo.yml run --rm --no-deps -u root layman bash -c "cd src && python3 -B setup_geoserver.py"
Expand Down Expand Up @@ -60,7 +60,7 @@ deps-stop:
docker compose -f docker-compose.deps.yml stop

start-dev:
mkdir -p layman_data layman_data_test tmp deps/qgis/data
mkdir -p layman_data layman_data_test tmp deps/qgis/data deps/wagtail/data
docker compose -f docker-compose.deps.yml -f docker-compose.dev.yml up -d postgresql
docker compose -f docker-compose.deps.yml -f docker-compose.dev.yml run --rm --no-deps -u root layman_dev bash -c "cd src && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.dev.yml up --force-recreate -d
Expand Down Expand Up @@ -107,7 +107,7 @@ upgrade-dev:
docker compose -f docker-compose.deps.yml -f docker-compose.dev.yml run --rm --no-deps layman_dev bash -c "cd src && python3 layman_flush_redis.py && python3 wait_for_deps.py && python3 standalone_upgrade.py"

prepare-dirs:
mkdir -p layman_data layman_data_test tmp deps/qgis/data
mkdir -p layman_data layman_data_test tmp deps/qgis/data deps/wagtail/data

build-dev:
docker compose -f docker-compose.deps.yml -f docker-compose.dev.yml build --force-rm layman_dev
Expand Down Expand Up @@ -143,7 +143,7 @@ reset-data-directories:
docker compose -f docker-compose.deps.yml rm -fsv
docker volume rm layman_redis-data || true
sudo rm -rf layman_data layman_data_test deps/*/data
mkdir -p layman_data layman_data_test tmp deps/qgis/data
mkdir -p layman_data layman_data_test tmp deps/qgis/data deps/wagtail/data

clear-python-cache-dev:
docker compose -f docker-compose.deps.yml -f docker-compose.dev.yml run --rm --no-deps layman_dev bash /code/src/clear-python-cache.sh
Expand Down Expand Up @@ -313,11 +313,16 @@ wagtail-exec:
docker compose -f docker-compose.deps.yml exec wagtail bash

wagtail-restart:
mkdir -p deps/wagtail/data
docker compose -f docker-compose.deps.yml up --force-recreate --no-deps -d wagtail

wagtail-stop:
docker compose -f docker-compose.deps.yml stop wagtail

wagtail-reset-datadir:
mkdir -p deps/wagtail/data
rm -rf deps/wagtail/data/*

micka-restart:
docker compose -f docker-compose.deps.yml up --force-recreate --no-deps -d micka

Expand Down
10 changes: 4 additions & 6 deletions deps/wagtail/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ RUN pip install -r /app/requirements.txt
# Copy the entire project code.
COPY laymanportal /app/

# Prepare the app.
RUN python manage.py migrate
# Prepare the app: migrations (not needed as db.sqlite3a was generated after migrations)
# RUN python manage.py migrate

# Prepare the app: collect static files
RUN python manage.py collectstatic --noinput

# Create a "coderedcms" user account to run the app.
RUN useradd coderedcms
RUN chown -R coderedcms /app/
USER coderedcms

# Finally, run the app on port 8000.
EXPOSE 8000
CMD exec waitress-serve --listen "*:8000" "laymanportal.wsgi:application"
2 changes: 1 addition & 1 deletion deps/wagtail/laymanportal/laymanportal/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
"NAME": os.path.join(BASE_DIR, "data/db.sqlite3"),
}
}

Expand Down
10 changes: 10 additions & 0 deletions deps/wagtail/laymanportal/start_wagtail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -ex

if [ ! -f /app/data/db.sqlite3 ]; then
echo "File db.sqlite3 not found, copying the default one."
cp /app/initial_data/db.sqlite3 /app/data/
fi

exec waitress-serve --listen "*:8000" "laymanportal.wsgi:application"
File renamed without changes.
4 changes: 4 additions & 0 deletions docker-compose.deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ services:
dockerfile: docker/Dockerfile
ports:
- 8083:8000
command: /app/start_wagtail.sh
volumes:
- ./deps/wagtail/data:/app/data/
- ./deps/wagtail/sample:/app/initial_data/

micka:
container_name: micka
Expand Down