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

docker compose setup #427

Merged
merged 6 commits into from
Jan 9, 2025
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
Binary file modified .docker/drupal/dumps/drupal.sql.gz
Binary file not shown.
Binary file added .docker/oidc-server-mock/cert/docker.pfx
Binary file not shown.
14,934 changes: 14,934 additions & 0 deletions .docker/pretix/dumps/pretix.sql

Large diffs are not rendered by default.

Binary file removed .docker/pretix/dumps/pretix.sql.gz
Binary file not shown.
20 changes: 11 additions & 9 deletions .docker/pretix/etc/pretix.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# https://docs.pretix.eu/en/latest/admin/installation/docker_smallscale.html#config-file
[pretix]
instance_name=http://pretix.hoeringsportal.local.itkdev.dk
instance_name=pretix.hoeringsportal.local.itkdev.dk
url=http://pretix.hoeringsportal.local.itkdev.dk
currency=DKK
datadir=/data
trust_x_forwarded_for=on
trust_x_forwarded_proto=on

[database]
backend=postgresql
name=pretix
user=pretix
password=pretix
host=pretix_database

[mail]
[email protected]
Expand All @@ -15,14 +25,6 @@ tls=False
[django]
debug=off

[database]
# backend=postgresql_psycopg2
backend=mysql
name=pretix
user=pretix
password=pretix
host=pretix_database

[redis]
location=redis://pretix_redis/0
sessions=true
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,33 @@ jobs:
- name: Update site
run: |
docker compose exec --user root phpfpm vendor/bin/drush deploy --yes

check-debug-patches:
name: Check that debug patches can be applied and reversed.
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
strategy:
matrix:
patch:
# Cf. documentation/openIdConnect.md
- patches/openid_connect-debug-userinfo.patch

steps:
- uses: actions/checkout@v4

- name: Start docker compose setup and install composer packages
run: |
docker network create frontend
docker compose pull
docker compose up --detach

# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec --user root phpfpm composer install --no-interaction

- name: Apply patch
run: |
docker compose exec --user root phpfpm patch --strip=1 --verbose --input=${{ matrix.patch }}

- name: Reverse patch
run: |
docker compose exec --user root phpfpm patch --strip=1 --verbose --input=${{ matrix.patch }} --reverse
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

* [PR-427](https://github.com/itk-dev/hoeringsportal/pull/427)
Updated docker compose setup. Updated composer packages.
* [PR-425](https://github.com/itk-dev/hoeringsportal/pull/425)
Publication dates
* [PR-424](https://github.com/itk-dev/hoeringsportal/pull/424)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
## Database dumps

The `docker compose` setup contains a couple of database dumps, one for Drupal
and one for pretix, to make it easy to get started. When adding new
functionality to Drupal, you may need to upgrade the database dump.
and one for pretix (see [Pretix setup](documentation/pretix.md) for details), to
make it easy to get started. When upgrading or adding new functionality to
Drupal, you may need to upgrade the database dump:

```sh
# Dump the database
docker compose exec phpfpm vendor/bin/drush sql:dump --extra-dump='--skip-column-statistics' --structure-tables-list="cache,cache_*,advancedqueue,history,search_*,sessions,watchdog" --gzip --result-file=/app/.docker/drupal/dumps/drupal.sql
task database-dump
```

## Setting up cron
Expand Down
131 changes: 131 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
version: '3'

# https://taskfile.dev/usage/#env-files
dotenv: ['.env.local', '.env']

vars:
# https://taskfile.dev/reference/templating/
BASE_URL: '{{.TASK_BASE_URL | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default "https://hoeringsportal.local.itkdev.dk"}}'
DOCKER_COMPOSE: '{{.TASK_DOCKER_COMPOSE | default "docker compose"}}'
COMPOSER_INSTALL_ARGUMENTS: '{{.TASK_COMPOSER_INSTALL_ARGUMENTS | default ""}}'

PRETIX_URL: '{{.TASK_PRETIX_URL | default "http://pretix.hoeringsportal.local.itkdev.dk"}}'
PRETIX_ORGANIZER: '{{.TASK_PRETIX_ORGANIZER | default "dpl-cms"}}'

tasks:
default:
cmds:
- task --list-all
silent: true

site-install:
prompt: "This will reset your setup. Continue?"
cmds:
- task compose -- down
- task compose -- pull
- task compose-up
- task composer-install
- task drush -- --yes site:install --existing-config
- task site-open
- task site-open-admin
silent: true

site-update:
cmds:
- task compose -- pull
- task compose-up
- task composer-install
- task drush -- deploy
silent: true

site-url:
cmds:
- task drush -- browse --no-browser
silent: true

site-open:
cmds:
- if command -v open 2>&1 >/dev/null; then open "$(task site-url)"; else echo "$(task site-url)"; fi
silent: true

site-open-admin:
cmds:
- if command -v open 2>&1 >/dev/null; then open "{{.URL}}"; else echo "{{.URL}}"; fi
vars:
URL:
sh: task drush -- user:login --no-browser
silent: true

compose:
cmds:
- '{{.DOCKER_COMPOSE}} --profile pretix {{.CLI_ARGS}}'

compose-up:
cmds:
- task compose -- up --detach --remove-orphans
silent: true

composer:
cmds:
- task compose -- exec phpfpm composer {{.CLI_ARGS}}

composer-install:
cmds:
- task composer -- install {{.COMPOSER_INSTALL_ARGUMENTS}} {{.CLI_ARGS}}
silent: true

drush:
cmds:
# Check if we have content on stdin (cf.
# https://unix.stackexchange.com/questions/762992/bash-check-if-the-standard-input-contains-anything)
- >-
if [[ ! -t 0 ]]; then
task compose -- exec --no-TTY phpfpm vendor/bin/drush --uri={{.BASE_URL}} {{.CLI_ARGS}};
else
task compose -- exec phpfpm vendor/bin/drush --uri={{.BASE_URL}} {{.CLI_ARGS}};
fi
silent: true

database-dump:
cmds:
# Make sure that site is up to date
- task site-update
- task drush -- sql:dump --extra-dump='--skip-column-statistics' --structure-tables-list="cache,cache_*,advancedqueue,history,search_*,sessions,watchdog" --gzip --result-file=/app/.docker/drupal/dumps/drupal.sql

pretix:
cmds:
- task compose -- exec pretix pretix {{.CLI_ARGS}}
silent: true

pretix:database-dump:
cmds:
- task compose -- exec --env PGPASSWORD=pretix pretix_database pg_dump --user=pretix pretix > .docker/pretix/dumps/pretix.sql

pretix:database-cli:
cmds:
- task compose -- exec --env PGPASSWORD=pretix pretix_database psql --user=pretix pretix

pretix:database-reset:
prompt: "This will reset your pretix database. Continue?"
cmds:
# Remove the pretix database container
- task compose -- rm pretix_database --stop --force
# Starting the container will load dump from .docker/pretix/dumps (cf. docker-compose.pretix.yml).
- task compose -- up --detach
# https://docs.pretix.eu/en/latest/admin/installation/docker_smallscale.html#updates
- task compose -- exec pretix pretix upgrade

pretix:database-load:
prompt: "This will reset your pretix database. Continue?"
cmds:
- task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --quiet --user=pretix pretix <<< "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
- task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --quiet --user=pretix pretix < .docker/pretix/dumps/pretix.sql
# https://docs.pretix.eu/en/latest/admin/installation/docker_smallscale.html#updates
- task pretix -- upgrade

pretix:api-ping:
vars:
API_TOKEN:
sh: task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --user=pretix pretix --tuples-only --csv <<< "SELECT token FROM pretixbase_teamapitoken WHERE name = 'hoeringsportal'"
cmds:
- "task compose -- exec phpfpm curl --header 'Authorization: Token {{.API_TOKEN}}' {{.PRETIX_URL}}/api/v1/organizers/"
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"drupal/viewsreference": "^2.0@beta",
"drupal/webform": "^6.2@beta",
"drupal/xls_serialization": "^1.2",
"drush/drush": "^12",
"drush/drush": "^13",
"itk-dev/composer-virtualenv": "^1.0",
"itk-dev/itk_azure_video": "^2.0",
"itk-dev/itk_pretix": "^1.0",
Expand All @@ -77,7 +77,7 @@
"webflo/drupal-finder": "^1.0.0"
},
"require-dev": {
"drupal/content_fixtures": "^3.1",
"drupal/content_fixtures": "dev-3498162-not-compatible-with",
"drupal/core-dev": "^10.0",
"drupal/masquerade": "^2.0",
"ergebnis/composer-normalize": "^2.44",
Expand All @@ -90,6 +90,11 @@
"drupal/drupal": "*"
},
"repositories": {
"drupal/content_fixtures": {
"type": "git",
"url": "https://git.drupalcode.org/issue/content_fixtures-3498162",
"//": "Content fixtures: Not compatible with Drush 13+ (https://www.drupal.org/project/content_fixtures/issues/3498162)"
},
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
Expand Down Expand Up @@ -280,7 +285,7 @@
"twig-cs-fixer lint web/themes/custom/hoeringsportal/templates"
],
"install-codestandards": [
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
"PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
]
}
}
Loading
Loading