kopia lustrzana https://github.com/wagtail/bakerydemo
Porównaj commity
4 Commity
532c3c9fff
...
3afae85a71
Autor | SHA1 | Data |
---|---|---|
John-Scott Atlakson | 3afae85a71 | |
Rohit Sharma | baff48b7d9 | |
John-Scott Atlakson | 6c20603929 | |
John-Scott Atlakson | b5fa7e89d1 |
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.
|
DJANGO_SETTINGS_MODULE=bakerydemo.settings.dev
|
||||||
# If the variables defined here are loaded into the environment, CSP will be enabled.
|
|
||||||
|
|
||||||
|
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
|
# These values are commented out by default because Wagtail is not (yet) compatible with
|
||||||
# the strict policy defined below.
|
# the strict policy defined below.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Build container
|
- name: Build container
|
||||||
run: docker-compose build && docker-compose pull
|
run: cp .env.example .env && docker-compose build && docker-compose pull
|
||||||
- name: Run migrations
|
- name: Run migrations
|
||||||
run: docker-compose run app /venv/bin/python manage.py migrate
|
run: docker-compose run app /venv/bin/python manage.py migrate
|
||||||
- name: Load initial data
|
- name: Load initial data
|
||||||
|
|
|
@ -16,7 +16,7 @@ jobs:
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: 3.12
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
cache-dependency-path: 'requirements/*.txt'
|
cache-dependency-path: 'requirements/*.txt'
|
||||||
- name: Install dependencies
|
- 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):
|
# Install packages needed to run your application (not build deps):
|
||||||
# We need to recreate the /usr/share/man/man{1..8} directories first because
|
# We need to recreate the /usr/share/man/man{1..8} directories first because
|
||||||
|
@ -33,7 +33,7 @@ RUN set -ex \
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
" \
|
" \
|
||||||
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
|
&& 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 -U pip \
|
||||||
&& pip install --no-cache-dir -r /requirements/production.txt \
|
&& pip install --no-cache-dir -r /requirements/production.txt \
|
||||||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
|
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
|
||||||
|
@ -45,9 +45,6 @@ ADD . /code/
|
||||||
ENV PORT 8000
|
ENV PORT 8000
|
||||||
EXPOSE 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:
|
# Call collectstatic with dummy environment variables:
|
||||||
RUN DATABASE_URL=postgres://none REDIS_URL=none python manage.py collectstatic --noinput
|
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
|
# mark the destination for images as a volume
|
||||||
VOLUME ["/code/bakerydemo/media/images/"]
|
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
|
# Start uWSGI
|
||||||
CMD ["uwsgi", "/code/etc/uwsgi.ini"]
|
CMD ["uwsgi", "/code/etc/uwsgi.ini"]
|
||||||
|
|
|
@ -480,7 +480,7 @@ class FormPage(AbstractEmailForm):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@register_setting
|
@register_setting(icon="cog")
|
||||||
class GenericSettings(ClusterableModel, BaseGenericSetting):
|
class GenericSettings(ClusterableModel, BaseGenericSetting):
|
||||||
twitter_url = models.URLField(verbose_name="Twitter URL", blank=True)
|
twitter_url = models.URLField(verbose_name="Twitter URL", blank=True)
|
||||||
github_url = models.URLField(verbose_name="GitHub URL", blank=True)
|
github_url = models.URLField(verbose_name="GitHub URL", blank=True)
|
||||||
|
@ -498,7 +498,7 @@ class GenericSettings(ClusterableModel, BaseGenericSetting):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@register_setting
|
@register_setting(icon="site")
|
||||||
class SiteSettings(BaseSiteSetting):
|
class SiteSettings(BaseSiteSetting):
|
||||||
title_suffix = models.CharField(
|
title_suffix = models.CharField(
|
||||||
verbose_name="Title suffix",
|
verbose_name="Title suffix",
|
||||||
|
|
|
@ -1,38 +1,40 @@
|
||||||
version: '2'
|
volumes:
|
||||||
|
postgres-data:
|
||||||
|
|
||||||
services:
|
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:
|
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:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ./bakerydemo:/code/bakerydemo
|
- ./bakerydemo:/code/bakerydemo
|
||||||
links:
|
|
||||||
- db:db
|
|
||||||
- redis:redis
|
|
||||||
ports:
|
ports:
|
||||||
- '8000:8000'
|
- '8000:8000'
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
db:
|
||||||
- redis
|
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
|
```bash
|
||||||
git clone https://github.com/wagtail/bakerydemo.git --config core.autocrlf=input
|
git clone https://github.com/wagtail/bakerydemo.git --config core.autocrlf=input
|
||||||
cd bakerydemo
|
cd bakerydemo
|
||||||
|
cp .env.example .env
|
||||||
docker compose up --build -d
|
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
|
```bash
|
||||||
docker compose run app /venv/bin/python manage.py migrate
|
docker compose exec app python manage.py migrate --noinput
|
||||||
docker compose run app /venv/bin/python manage.py load_initial_data
|
docker compose exec app python manage.py load_initial_data
|
||||||
```
|
docker compose exec app python manage.py update_index
|
||||||
If this fails with a database error, wait 10 more seconds and re-try. Finally, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose up
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The demo site will now be accessible at [http://localhost:8000/](http://localhost:8000/) and the Wagtail admin
|
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
|
#### 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/)
|
- [Virtualenv](https://virtualenv.pypa.io/en/stable/installation/)
|
||||||
- [VirtualenvWrapper](https://virtualenvwrapper.readthedocs.io/en/latest/install.html) (optional)
|
- [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
|
deactivate
|
||||||
rmvirtualenv wagtailbakerydemo
|
rmvirtualenv wagtailbakerydemo
|
||||||
mkvirtualenv wagtailbakerydemo --python=python3.9
|
mkvirtualenv wagtailbakerydemo --python=python3.12
|
||||||
python --version
|
python --version
|
||||||
|
|
||||||
Now we're ready to set up the bakery demo project itself:
|
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 migrate
|
||||||
./manage.py load_initial_data
|
./manage.py load_initial_data
|
||||||
|
./manage.py update_index
|
||||||
./manage.py runserver
|
./manage.py runserver
|
||||||
|
|
||||||
Log into the admin with the credentials `admin / changeme`.
|
Log into the admin with the credentials `admin / changeme`.
|
||||||
|
|
Ładowanie…
Reference in New Issue