Skip to content

Commit

Permalink
Update Docker containers
Browse files Browse the repository at this point in the history
This change will update the docker container to Python 3.8 and Postgres container to 12.2. It removes the Elasticsearch container, which seemed unnecessary. This change also ensures that the regulations_example app functions, and adds some example data.
  • Loading branch information
willbarton committed Mar 23, 2020
1 parent 3b539f2 commit cbb67fb
Show file tree
Hide file tree
Showing 8 changed files with 854 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-slim
FROM python:3.8-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
Expand Down Expand Up @@ -35,7 +35,7 @@ RUN set -ex \
zlib1g-dev \
" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
&& python3.7 -m venv /venv \
&& python3.8 -m venv /venv \
&& /venv/bin/pip install -U pip \
&& /venv/bin/pip install --no-cache-dir -r /code/regulations_example/requirements.txt \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Building blocks for interactive regulations in Wagtail.

## Usage


### Components

Wagtail Regulations provides the building blocks to create and serve
Expand Down Expand Up @@ -79,6 +78,29 @@ The frontend serves the regulation content and search to end users.

### Putting it all together

This repository comes with the Wagtail library to build an interative federal
regulations website as well as a functioning example of how to do so.

The example is broken into a Wagtail-based REST API and a Gatsy-based
front-end using the US Web Design System v2.0 that consumes that API.

#### API

The API can be run using
[Docker](https://docs.docker.com/engine/installation/) with
[Docker Compose](https://docs.docker.com/compose/install/):

```
docker-compose up
```

To load example regulation data with the necessary Wagtail pages:

```
docker-compose run app /venv/bin/python manage.py loaddata sample_data.json
```

The regulation data should then be available at http://localhost:8000/api/v2/pages/4


## Getting help
Expand Down
10 changes: 1 addition & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,24 @@ services:
POSTGRES_USER: app_user
POSTGRES_PASSWORD: changeme
restart: always
image: postgres:9.6
image: postgres:12.2
expose:
- "5432"
elasticsearch:
image: elasticsearch:2.3
restart: always
expose:
- "9200"
app:
environment:
DJANGO_SECRET_KEY: changeme
DATABASE_URL: postgres://app_user:changeme@db/app_db
ELASTICSEARCH_ENDPOINT: elasticsearch
build:
context: .
dockerfile: ./Dockerfile
volumes:
- ./:/code
links:
- db:db
- elasticsearch:elasticsearch
ports:
- "8000:8000"
depends_on:
- db
- elasticsearch
volumes:
media-root:

2 changes: 2 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ done

>&2 echo "Postgres is up - continuing"

/venv/bin/python manage.py migrate --noinput

exec "$@"
808 changes: 808 additions & 0 deletions regulations_example/fixtures/sample_data.json

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions regulations_example/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.27 on 2020-01-27 11:03
# Generated by Django 2.2.11 on 2020-03-23 17:41

from django.db import migrations, models
import django.db.models.deletion

from wagtail.contrib.routable_page.models import RoutablePageMixin
from wagtail.core import blocks
from wagtail.core import fields
import wagtail.contrib.routable_page.models
import wagtail.core.blocks
import wagtail.core.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailregulations', '__first__'),
('wagtailcore', '0040_page_draft_title'),
('wagtailregulations', '0001_initial'),
('wagtailcore', '0045_assign_unlock_grouppagepermission'),
]

operations = [
migrations.CreateModel(
name='TestRegulationLandingPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('body', fields.StreamField((('title', blocks.CharBlock()), ('introduction', blocks.RichTextBlock()), ('regulations_list', blocks.StructBlock((('heading', blocks.CharBlock(help_text='Regulations list heading', required=False)), ('more_regs_page', blocks.PageChooserBlock(help_text='Link to more regulations')), ('more_regs_text', blocks.CharBlock(help_text='Text to show on link to more regulations', required=False)))))))),
('body', wagtail.core.fields.StreamField([('title', wagtail.core.blocks.CharBlock()), ('introduction', wagtail.core.blocks.RichTextBlock()), ('regulations_list', wagtail.core.blocks.StructBlock([]))])),
],
options={
'abstract': False,
},
bases=(RoutablePageMixin, 'wagtailcore.page'),
bases=(wagtail.contrib.routable_page.models.RoutablePageMixin, 'wagtailcore.page'),
),
migrations.CreateModel(
name='TestRegulationPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('body', fields.StreamField((('title', blocks.CharBlock()), ('introduction', blocks.RichTextBlock())))),
('body', wagtail.core.fields.StreamField([('title', wagtail.core.blocks.CharBlock()), ('introduction', wagtail.core.blocks.RichTextBlock())])),
('regulation', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='page', to='wagtailregulations.Part')),
],
options={
'abstract': False,
},
bases=(RoutablePageMixin, 'wagtailcore.page', models.Model),
bases=(wagtail.contrib.routable_page.models.RoutablePageMixin, 'wagtailcore.page', models.Model),
),
]
5 changes: 3 additions & 2 deletions regulations_example/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ Django>=2.2,<2.3
django-extensions==2.2.6
django-dotenv==1.4.1
wagtail>=2.8,<2.9
Pillow<6.0,>=4.0.0
Pillow<6.0,>=6.2.0
elasticsearch==2.4.1
dj-database-url==0.4.1
lxml==4.4.2
python-dateutil==2.8.1
psycopg2>=2.7,<3.0
wagtail-treemodeladmin>=1.0.4,<1.1
wagtail-treemodeladmin
wagtail-copyablemodeladmin
regdown>=1.0.1,<1.2
whitenoise==3.2.2
4 changes: 4 additions & 0 deletions regulations_example/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os
from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

0 comments on commit cbb67fb

Please sign in to comment.