-
Notifications
You must be signed in to change notification settings - Fork 1
chore: update config #14
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
Changes from 11 commits
a91bd46
7f06c15
994c150
8f74362
56cc29b
2ac1e42
e8dd7e6
4ba9eac
911fc9e
7e4b890
7b15faf
1f933f7
80a884c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,10 @@ services: | |
| database: | ||
| type: mariadb:10.5.23 | ||
| portforward: 32778 | ||
| creds: | ||
| user: pressbooks_oss_user | ||
| password: secretpassword | ||
| database: pressbooks_oss | ||
| redis: | ||
| type: redis:5.0 | ||
| portforward: 6380 | ||
|
|
@@ -32,13 +36,16 @@ services: | |
| - scripts/pressbooks_required_libraries.sh | ||
| build: | ||
| - composer install | ||
| run_as_root: | ||
|
||
| - bash /app/scripts/import_db.sh /app/pb_local_db.sql | ||
| - bash /app/scripts/prepare_test_environment.sh | ||
| mailhog: | ||
| hogfrom: | ||
| - appserver | ||
| type: mailhog | ||
| overrides: | ||
| image: anatomicjc/mailhog:1.0.1 | ||
| portforward: 8026 | ||
| portforward: 8026 | ||
| tooling: | ||
| php: | ||
| service: appserver | ||
|
|
@@ -50,8 +57,8 @@ tooling: | |
| service: node | ||
| install-tests: | ||
| description: Install test requirements | ||
| cmd: | ||
| - appserver: scripts/prepare_tests_environment.sh | ||
| cmd: | ||
| - appserver: scripts/prepare_test_environment.sh | ||
| test: | ||
| description: Run all Unit Tests | ||
| cmd: | ||
|
|
@@ -68,3 +75,8 @@ tooling: | |
| description: Run tests by filter | ||
| cmd: | ||
| - appserver: composer run filter_test | ||
| db-import-custom: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add new command for performing custom database import. Can remove after lando/core#384 is released |
||
| description: Import a SQL dump into the database defined in .env | ||
| cmd: | ||
| - appserver: scripts/import_db.sh | ||
| user: root | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,28 +37,22 @@ This repository uses Lando/Docker to provision a local instance of Pressbooks fo | |
| ```bash | ||
| lando start | ||
| ``` | ||
| During the build process, you may be asked for an installation folder for Prince: | ||
| This will create all the services needed to install a local instance of Pressbooks and import a sample database. During the build process, you may be asked for an installation folder for Prince: | ||
| ```bash | ||
| Install directory | ||
| This is the directory in which Prince 20220930 will be installed. | ||
| Press Enter to accept the default directory or enter an alternative. | ||
| [/usr]: | ||
| ``` | ||
| Press `Enter` to accept the default directory. | ||
| 8. Import the prepared sample database included in this repo: | ||
| ```bash | ||
| lando db-import pb_local_db.sql | ||
| ``` | ||
| 9. Install Pressbooks testing utilities | ||
| ```bash | ||
| lando install-tests | ||
| ``` | ||
| 10. [Optional] Tell your host machine to trust the default Lando Certificate Authority by following these instructions: https://docs.lando.dev/core/v3/security.html#trusting-the-ca | ||
| 8. [Optional] Tell your host machine to trust the default Lando Certificate Authority by following these instructions: https://docs.lando.dev/core/v3/security.html#trusting-the-ca | ||
|
|
||
| ### Web access | ||
| Once you have completed these steps, you should be able to use Pressbooks locally by visiting `http://pressbooks.test` or `https://pressbooks.test`. | ||
|
|
||
| ### Running tests | ||
| Everything needed to run unit tests will be provided when you run `lando start`. You can re-install the Pressbooks test suite by running `lando install-tests`. | ||
|
|
||
| You can run tests inside your Lando instance with the following commands: | ||
| `lando test` (this is a shortcut which runs the core Pressbooks unit tests inside your container) | ||
|
|
||
|
|
@@ -79,13 +73,14 @@ You can set up access to your database in your IDE by creating a new MariaDB con | |
| 2. In PHPStorm, open the `Database` menu (on the right side of the IDE), click the `+` button and add a new `MariaDB` connection. | ||
| 3. Enter the following connection data: | ||
| - The `host` and `port` values obtained by running `lando info` earlier | ||
| - user: wordpress | ||
| - password: wordpress | ||
| - database: wordpress | ||
| - user: pressbooks_oss_user | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update values to match new defaults |
||
| - password: secretpassword | ||
| - database: pressbooks_oss | ||
|
|
||
| ### Notes | ||
| - The sample database includes a single empty public book and a single super admin user with a username / password of `admin / admin`. | ||
| - The `.env.example` file provides some additional environment variables which can be used with your local Pressbooks installation but are commented out by default. If you wish to install the optional PB MathJax service, you can do so following the instructions here: https://github.com/pressbooks/pb-mathjax?tab=readme-ov-file#installation. Once you've launched the service, you can uncomment the relevant line in your local `.env` file. Similar sample `.env` variables are provided for optional DocRaptor, Sentry, Redis, and Algolia integrations. | ||
| - You can force a reimport of the sample DB by running `lando db-import-custom pb_local_db.sql --force` | ||
| - `lando info` provides a list of all the services and their ports. | ||
| - You can install or update dependencies in the container or any repo by navigating to the desired location and running `lando composer install` or `lando composer update`. | ||
| - For SSH access to the appserver you can run: `lando ssh` or `lando ssh -u root` (if you wish to access the appserver as the root user) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/bin/bash | ||
| # Safe automatic DB import for Lando with optional force import | ||
| # Usage: | ||
| # ./import_db.sh /app/pb_local_db.sql # safe import, skips if DB exists | ||
| # ./import_db.sh --force /app/pb_local_db.sql # force re-import | ||
|
|
||
| FORCE=false | ||
| SQL_FILE="" | ||
|
|
||
| # Parse arguments | ||
| for arg in "$@"; do | ||
| case $arg in | ||
| --force|-f) | ||
| FORCE=true | ||
| shift | ||
| ;; | ||
| *) | ||
| SQL_FILE="$arg" | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ -z "$SQL_FILE" ]; then | ||
| echo "Usage: $0 [--force|-f] <file.sql>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Load environment variables from .env | ||
| set -a | ||
| source /app/.env | ||
| set +a | ||
|
|
||
| if [ "$FORCE" = false ]; then | ||
| # Check if database exists | ||
| DB_EXISTS=$(mysql -h "$DB_HOST" -P 3306 -u "$DB_USER" -p"$DB_PASSWORD" -e "SHOW DATABASES LIKE '$DB_NAME';" | grep "$DB_NAME") | ||
|
|
||
| if [ -n "$DB_EXISTS" ]; then | ||
| echo "Database '$DB_NAME' exists. Skipping import." | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| echo "Database '$DB_NAME' will be created/imported..." | ||
|
|
||
| # Drop and recreate DB if force is true | ||
| if [ "$FORCE" = true ]; then | ||
| mysql -h "$DB_HOST" -P 3306 -u "$DB_USER" -p"$DB_PASSWORD" -e "DROP DATABASE IF EXISTS $DB_NAME;" | ||
| fi | ||
|
|
||
| # Ensure database exists | ||
| mysql -h "$DB_HOST" -P 3306 -u "$DB_USER" -p"$DB_PASSWORD" -e "CREATE DATABASE IF NOT EXISTS $DB_NAME;" | ||
|
|
||
| # Import SQL | ||
| mysql -h "$DB_HOST" -P 3306 -u "$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" < "$SQL_FILE" | ||
|
|
||
| echo "Import complete!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create database with credentials matching those now provided in .env.example