-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a91bd46
chore: update config
SteelWagstaff 7f06c15
chore: update composer.json
SteelWagstaff 994c150
chore: add db creds to lando recipe
SteelWagstaff 8f74362
chore: add custom db import script
SteelWagstaff 56cc29b
chore: update readme
SteelWagstaff 2ac1e42
chore: simplify install steps
SteelWagstaff e8dd7e6
Merge branch 'dev' into chore/update-config
SteelWagstaff 4ba9eac
fix: imporve scripts and run order
SteelWagstaff 911fc9e
chore: improve readme ^ build steps
SteelWagstaff 7e4b890
chore: clean up test installation
SteelWagstaff 7b15faf
chore: fix typo
SteelWagstaff 1f933f7
bump node, import database only on build
arzola 80a884c
better event for db import
arzola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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,6 +36,8 @@ services: | |
| - scripts/pressbooks_required_libraries.sh | ||
| build: | ||
| - composer install | ||
| run_as_root: | ||
| - bash /app/scripts/prepare_test_environment.sh | ||
| mailhog: | ||
| hogfrom: | ||
| - appserver | ||
|
|
@@ -51,7 +57,7 @@ tooling: | |
| install-tests: | ||
| description: Install test requirements | ||
| cmd: | ||
| - appserver: scripts/prepare_tests_environment.sh | ||
| - appserver: scripts/prepare_test_environment.sh | ||
| test: | ||
| description: Run all Unit Tests | ||
| cmd: | ||
|
|
@@ -68,3 +74,11 @@ 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 | ||
| events: | ||
| post-start: | ||
| - database: bash /app/scripts/import_db.sh /app/pb_local_db.sql | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/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 | ||
|
|
||
| # Create .env from .env.example if .env doesn't exist | ||
| if [ ! -f /app/.env ]; then | ||
| cp /app/.env.example /app/.env | ||
| echo "Created .env from .env.example" | ||
| fi | ||
|
|
||
| # Load environment variables from .env | ||
| set -a | ||
| source /app/.env | ||
| set +a | ||
|
|
||
| if [ "$FORCE" = false ]; then | ||
| # Check if WordPress tables exist or if database is empty | ||
| WP_TABLES=$(mysql -h "$DB_HOST" -P 3306 -u "$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" -e "SHOW TABLES LIKE 'wp_%';" 2>/dev/null | wc -l) | ||
|
|
||
| if [ "$WP_TABLES" -gt 0 ]; then | ||
| echo "Database '$DB_NAME' contains WordPress tables. 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!" |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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