kopia lustrzana https://github.com/wagtail/bakerydemo
Merge 6c20603929
into baff48b7d9
commit
3afae85a71
15
.env.example
15
.env.example
|
@ -1,6 +1,17 @@
|
|||
# This file contains Content Security Policy (CSP) directives to test Wagtail's compatibility with CSP.
|
||||
# If the variables defined here are loaded into the environment, CSP will be enabled.
|
||||
DJANGO_SETTINGS_MODULE=bakerydemo.settings.dev
|
||||
|
||||
REDIS_URL=redis://redis
|
||||
|
||||
# Database connection settings:
|
||||
DATABASE_HOST=db
|
||||
DATABASE_PORT=5432
|
||||
DATABASE_NAME=app_db
|
||||
DATABASE_USER=app_user
|
||||
DATABASE_PASSWORD=changeme
|
||||
DATABASE_URL=postgres://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST/$DATABASE_NAME
|
||||
|
||||
# Content Security Policy (CSP)
|
||||
# To test Wagtail's compatibility with CSP, configure the variables below to enable CSP.
|
||||
# These values are commented out by default because Wagtail is not (yet) compatible with
|
||||
# the strict policy defined below.
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build container
|
||||
run: docker-compose build && docker-compose pull
|
||||
run: cp .env.example .env && docker-compose build && docker-compose pull
|
||||
- name: Run migrations
|
||||
run: docker-compose run app /venv/bin/python manage.py migrate
|
||||
- name: Load initial data
|
||||
|
|
|
@ -16,7 +16,7 @@ jobs:
|
|||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.9
|
||||
python-version: 3.12
|
||||
cache: 'pip'
|
||||
cache-dependency-path: 'requirements/*.txt'
|
||||
- name: Install dependencies
|
||||
|
|
10
Dockerfile
10
Dockerfile
|
@ -1,4 +1,4 @@
|
|||
FROM python:3.9-slim
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Install packages needed to run your application (not build deps):
|
||||
# We need to recreate the /usr/share/man/man{1..8} directories first because
|
||||
|
@ -33,7 +33,7 @@ RUN set -ex \
|
|||
zlib1g-dev \
|
||||
" \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
|
||||
&& python3.9 -m venv ${VIRTUAL_ENV} \
|
||||
&& python3 -m venv ${VIRTUAL_ENV} \
|
||||
&& pip install -U pip \
|
||||
&& pip install --no-cache-dir -r /requirements/production.txt \
|
||||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
|
||||
|
@ -45,9 +45,6 @@ ADD . /code/
|
|||
ENV PORT 8000
|
||||
EXPOSE 8000
|
||||
|
||||
# Add custom environment variables needed by Django or your settings file here:
|
||||
ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
|
||||
|
||||
# Call collectstatic with dummy environment variables:
|
||||
RUN DATABASE_URL=postgres://none REDIS_URL=none python manage.py collectstatic --noinput
|
||||
|
||||
|
@ -57,8 +54,5 @@ RUN mkdir -p /code/bakerydemo/media/images && mkdir -p /code/bakerydemo/media/or
|
|||
# mark the destination for images as a volume
|
||||
VOLUME ["/code/bakerydemo/media/images/"]
|
||||
|
||||
# start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
|
||||
ENTRYPOINT ["/code/docker-entrypoint.sh"]
|
||||
|
||||
# Start uWSGI
|
||||
CMD ["uwsgi", "/code/etc/uwsgi.ini"]
|
||||
|
|
|
@ -1,38 +1,40 @@
|
|||
version: '2'
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
services:
|
||||
db:
|
||||
environment:
|
||||
POSTGRES_DB: app_db
|
||||
POSTGRES_USER: app_user
|
||||
POSTGRES_PASSWORD: changeme
|
||||
restart: unless-stopped
|
||||
image: postgres:14.1
|
||||
expose:
|
||||
- '5432'
|
||||
|
||||
redis:
|
||||
restart: unless-stopped
|
||||
image: redis:6.2
|
||||
expose:
|
||||
- '6379'
|
||||
|
||||
app:
|
||||
environment:
|
||||
DJANGO_SECRET_KEY: changeme
|
||||
DATABASE_URL: postgres://app_user:changeme@db/app_db
|
||||
REDIS_URL: redis://redis
|
||||
DJANGO_SETTINGS_MODULE: bakerydemo.settings.dev
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
volumes:
|
||||
- ./bakerydemo:/code/bakerydemo
|
||||
links:
|
||||
- db:db
|
||||
- redis:redis
|
||||
ports:
|
||||
- '8000:8000'
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
|
||||
db:
|
||||
environment:
|
||||
- "POSTGRES_DB=${DATABASE_NAME}"
|
||||
- "POSTGRES_USER=${DATABASE_USER}"
|
||||
- "POSTGRES_PASSWORD=${DATABASE_PASSWORD}"
|
||||
restart: unless-stopped
|
||||
image: postgres:16
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: "pg_isready --quiet --dbname=${DATABASE_URL}"
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
restart: unless-stopped
|
||||
image: redis:7
|
||||
expose:
|
||||
- '6379'
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "redis-cli ping || exit 1"]
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
until psql $DATABASE_URL -c '\q'; do
|
||||
>&2 echo "Postgres is unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up - continuing"
|
||||
|
||||
if [ "$1" = '/venv/bin/uwsgi' ]; then
|
||||
/venv/bin/python manage.py migrate --noinput
|
||||
fi
|
||||
|
||||
if [ "x$DJANGO_LOAD_INITIAL_DATA" = 'xon' ]; then
|
||||
/venv/bin/python manage.py load_initial_data
|
||||
fi
|
||||
|
||||
exec "$@"
|
18
readme.md
18
readme.md
|
@ -89,19 +89,16 @@ Run the following commands:
|
|||
```bash
|
||||
git clone https://github.com/wagtail/bakerydemo.git --config core.autocrlf=input
|
||||
cd bakerydemo
|
||||
cp .env.example .env
|
||||
docker compose up --build -d
|
||||
```
|
||||
|
||||
After this command completes and returns to the command prompt, wait 10 more seconds for the database setup to complete. Then run:
|
||||
After this command completes and returns to the command prompt, run:
|
||||
|
||||
```bash
|
||||
docker compose run app /venv/bin/python manage.py migrate
|
||||
docker compose run app /venv/bin/python manage.py load_initial_data
|
||||
```
|
||||
If this fails with a database error, wait 10 more seconds and re-try. Finally, run:
|
||||
|
||||
```bash
|
||||
docker compose up
|
||||
docker compose exec app python manage.py migrate --noinput
|
||||
docker compose exec app python manage.py load_initial_data
|
||||
docker compose exec app python manage.py update_index
|
||||
```
|
||||
|
||||
The demo site will now be accessible at [http://localhost:8000/](http://localhost:8000/) and the Wagtail admin
|
||||
|
@ -125,7 +122,7 @@ You can run the Wagtail demo locally without setting up Vagrant or Docker and si
|
|||
|
||||
#### Dependencies
|
||||
|
||||
- Python 3.7, 3.8, 3.9, 3.10 or 3.11
|
||||
- Python 3.8, 3.9, 3.10, 3.11, or 3.12
|
||||
- [Virtualenv](https://virtualenv.pypa.io/en/stable/installation/)
|
||||
- [VirtualenvWrapper](https://virtualenvwrapper.readthedocs.io/en/latest/install.html) (optional)
|
||||
|
||||
|
@ -141,7 +138,7 @@ Confirm that this is showing a compatible version of Python 3.x. If not, and you
|
|||
|
||||
deactivate
|
||||
rmvirtualenv wagtailbakerydemo
|
||||
mkvirtualenv wagtailbakerydemo --python=python3.9
|
||||
mkvirtualenv wagtailbakerydemo --python=python3.12
|
||||
python --version
|
||||
|
||||
Now we're ready to set up the bakery demo project itself:
|
||||
|
@ -161,6 +158,7 @@ To set up your database and load initial data, run the following commands:
|
|||
|
||||
./manage.py migrate
|
||||
./manage.py load_initial_data
|
||||
./manage.py update_index
|
||||
./manage.py runserver
|
||||
|
||||
Log into the admin with the credentials `admin / changeme`.
|
||||
|
|
Ładowanie…
Reference in New Issue