Skip to content
Draft
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
27 changes: 18 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,35 @@ help: ## ⁉️ - Display help comments for each make command
| sort

setup: build ## 🔨 - Set instance up
docker-compose run web django-admin migrate
docker-compose run web django-admin createcachetable
docker compose run web django-admin migrate
docker compose run web django-admin createcachetable

build: ## 🔨 - Build Docker container
bash -c "docker-compose build --build-arg UID=$$(id -u) --build-arg GID=$$(id -g)"
bash -c "docker compose build --build-arg UID=$$(id -u) --build-arg GID=$$(id -g)"

start: ## 🎬 - Start containers
docker-compose up
docker compose up

sh: ## Enter the web container
docker-compose exec web bash
docker compose exec web bash

runserver: ## 🏃 - Run Django server
docker-compose exec web django-admin runserver 0.0.0.0:8000
docker compose exec web django-admin runserver 0.0.0.0:8000

superuser: ## 🔒 - Create superuser
docker-compose run web django-admin createsuperuser
docker compose run web django-admin createsuperuser

migrations: ## 🧳 - Make migrations
docker-compose run web django-admin makemigrations
docker compose run web django-admin makemigrations

migrate: ## 🧳 - Migrate
docker-compose run web django-admin migrate
docker compose run web django-admin migrate

dumpfixtures: # 📦 - Dump fixtures
docker compose run --rm web django-admin dumpdata --natural-foreign --indent 2 -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailimages.rendition -e sessions -e wagtailsearch.indexentry -e wagtailcore.referenceindex -e wagtailcore.pagesubscription -e wagtailcore.workflowcontenttype -e wagtailadmin.editingsession -e wagtailio.wagtailiorendition > fixtures/wagtail.org-demo.json
npx prettier --write fixtures/wagtail.org-demo.json
docker compose run --rm web cp -r media/original_images/* fixtures/media/original_images
docker compose run --rm web cp -r media/documents/* fixtures/media/documents

load_initial_data: # 📦 - Load initial data
docker-compose run --rm web django-admin load_initial_data
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ You first need to install [Docker](https://docs.docker.com/get-docker/) and [Doc
git clone https://github.com/wagtail/wagtail.org.git
cd wagtail.org
make setup
make load_initial_data
```

This will create a set of Docker containers on your local machine and also create a blank database.
This will create a set of Docker containers on your local machine and also create a database filled with initial data for you to work with.

### Starting the development environment

Expand All @@ -43,13 +44,12 @@ To run migrations within Docker you'll need to run:
make migrate
```

### Creating a superuser
### Logging in to the Wagtail admin

To create a new superuser locally, run:
The initial data includes a superuser with the following credentials:

```
make superuser
```
- Username: `admin`
- Password: `changeme`

### Setting up the cache table

Expand Down Expand Up @@ -81,6 +81,14 @@ Access will only be given when absolutely necessary.

If you're on Windows, we recommend you follow the [specific steps for Windows.](#pulling-staging-data-on-windows)

### Dumping your database to a fixture

Fixtures allow you to export your database to a JSON file, which is useful for populating the database with demo content or to share a snapshot of the database with others. To dump your database (and media files) to fixtures, run the following command:

```
make dumpfixtures
```

## Installation (Vagrant)

You first need to install [Vagrant](https://www.vagrantup.com/) and [Virtualbox](https://www.virtualbox.org/). Once they are installed, run the following commands to get up and running:
Expand All @@ -93,13 +101,15 @@ vagrant up

This will download the base image and provision a local VM that will run the site locally.

You will need to apply migrations, create a super user, and create a cache table once the vagrant environment is setup.
You will need to apply migrations, create a super user, create a cache table and
load the initial data once the vagrant environment is setup.

```
vagrant ssh
./manage.py migrate
./manage.py createsuperuser
./manage.py createcachetable
./manage.py load_initial_data
```

## Usage (Vagrant)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
target: dev
init: true
# This command just starts the container and keeps it running.
# To run a command within the container run docker-compose exec web <command>
# To run a command within the container run docker compose exec web <command>
# A Makefile task exists that starts a development server in the container: make runserver
command: tail -f /dev/null
environment:
Expand Down
4 changes: 2 additions & 2 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


def dexec(cmd, service="web"):
return local(f"docker-compose exec -T {quote(service)} bash -c {quote(cmd)}")
return local(f"docker compose exec -T {quote(service)} bash -c {quote(cmd)}")


@task
Expand All @@ -44,7 +44,7 @@ def psql(c, command=None):
Connect to the local postgres DB using psql
"""
cmd_list = [
"docker-compose",
"docker compose",
"exec",
"db",
"psql",
Expand Down
Binary file added fixtures/media/documents/test_doc.pdf
Binary file not shown.
Binary file added fixtures/media/original_images/GSoc-2022.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading