TugboatQA / docs

Tugboat Docs
https://docs.tugboat.qa
MIT License
9 stars 18 forks source link

Document how to pull data from platform.sh #298

Open q0rban opened 3 years ago

nlighteneddesign commented 3 years ago

We use Platform.sh in a mulitapp architecture. This means that we have several Drupal sites in one project, they are not multisites. In order to achieve this there is a main repositories that uses git submodules to point to the actual Drupal repositories. Because of this there are a few steps that required for us that may not be required for more standard installs.

In the tugboat repository settings we need an environment variable for the platform cli it must be named PLATFORMSH_CLI_TOKEN Instructions for generating the token: https://docs.platform.sh/development/cli/api-tokens.html

In the php service init command we install the platform.sh cli:

# Install platform cli
- curl -fsS https://platform.sh/cli/installer | php

In the php service update command we grab the database.

- /root/.platformsh/bin/platform --project=${PROJECT_ID} --environment=${BRANCH} --app=${APP} --relationship=${DATABASE} db:dump --gzip
- vendor/bin/drush sql-drop -y
- zcat ${PROJECT_ID}--${BRANCH}-${CUSTOMER_ID}--mariadb--${APP}--dump.sql.gz | mysql --host=mysql -u tugboat -ptugboat tugboat
- rm ${PROJECT_ID}--${BRANCH}-${CUSTOMER_ID}--mariadb--${APP}--dump.sql.gz

${PROJECT_ID} is the id of the project you can see it in the url when you are on the platform dashboard looking at the project. ${BRANCH} is the branch/environment you want to pull the database from usually main or master. ${APP} is the name of the app defined in .platform.app.yaml ${DATABASE} is the name of the database relationship in .platform.app.yaml ${CUSTOMER_ID} can be found in the default urls that platform provides each project.

I also assume mariadb in the string depends on the service you use for your database, but I only have mariadb on platform.

We do not need the typical mysql update command that is there by default.