diff --git a/.dbdumps/.gitkeep b/.dbdumps/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.ddev/commands/web/fetch-db b/.ddev/commands/web/fetch-db new file mode 100755 index 0000000..754d18a --- /dev/null +++ b/.ddev/commands/web/fetch-db @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +## Description: Fetches a DB dump +## Usage: fetch-db +## Example: ddev fetch-db + +mysqldump \ + --host="${REMOTE_HOST}" \ + --user="${REMOTE_DB_USER}" \ + --password="${REMOTE_DB_PASSWORD}" \ + --single-transaction \ + --no-tablespaces \ + "${REMOTE_DB}" > ".dbdumps/${REMOTE_DB}_$(date +"%Y-%m-%dT%Y-%H%M").sql" diff --git a/.ddev/commands/web/fetch-files b/.ddev/commands/web/fetch-files new file mode 100755 index 0000000..aa02e58 --- /dev/null +++ b/.ddev/commands/web/fetch-files @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +## Description: Fetches the files directory content +## Usage: fetch-files +## Example: ddev fetch-files + +rclone sync \ + --sftp-host "${REMOTE_HOST}" \ + --sftp-user "${REMOTE_FTP_USER}" \ + --sftp-port "${REMOTE_FTP_PORT}" \ + --sftp-pass "$(rclone obscure ${REMOTE_FTP_PASSWORD})" \ + --progress \ + --quiet \ + :sftp:web/sites/default/files web/sites/default/files diff --git a/.ddev/config.yaml b/.ddev/config.yaml index acb6493..f4475ec 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -14,3 +14,5 @@ timezone: Europe/Zurich composer_version: "2" web_environment: [] corepack_enable: true +webimage_extra_packages: + - rclone diff --git a/.gitignore b/.gitignore index 057701b..211d97a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,10 @@ # Ignore multi-site test environment. /web/sites/simpletest + +# Ignore ddev secrets +/.ddev/.env + +# DB dump directory +!/.dbdump/.gitkeep +/.dbdump/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..f709988 --- /dev/null +++ b/README.md @@ -0,0 +1,106 @@ +# SWISS ARTG Homepage + +This repository holds the codebase for the homepage of the SWISS Amateur Radio Teletype Group. + +## Principles + +This repository is the source of truth. +Changes made in this repository will be pushed the hosting. +Consequently, changes made directly on the hosting will be reverted. + +Using [DDEV][ddev], a local development environment provides a save space to do code changes before they are being pushed to the hosting. + +The Drupal Configuration Management is used to export site configuration to config files tracked within this repository. +Changes to the site must be done in the local development environment first and then pushed to the hosting through code changes. + +## Set up a local development environment + +### Prerequisites + +* A working installation of [DDEV][ddev]. + See its [documentation](https://ddev.com/get-started/) on how to get started on your platform. +* A git client. + Checkout the [git download page](https://git-scm.com/downloads) on how to get it for your platform. +* Read-only access to the database on the hosting. +* FTP access to the hosting. + +### Procedure + +1. Clone the source code + + ```sh + git clone git@github.com:swiss-artg/homepage.git swiss-artg + ``` + + The folder `swiss-artg` will be referred to as _repository root_. + +2. Configure the database access + + Create the file `.ddev/.env` using the text editor of your choice with the following content. + + ``` + REMOTE_HOST= + REMOTE_DB= + REMOTE_DB_USER= + REMOTE_DB_PASSWORD= + REMOTE_FTP_USER= + REMOTE_FTP_PASSWORD= + REMOTE_FTP_PORT= + ``` + + Replace all instances of `<…>` with the values you received from a site administrator. + + Protect the file from prying eyes. + + ```sh + chmod 600 .ddev/.env + ``` + +3. Start the DDEV environment + + Execute this from within the repository root. + + ```sh + ddev start + ``` + +4. Install the dependencies + + ```sh + ddev composer install + ``` + +5. Fetch content from the hosting + + ```sh + ddev fetch-db + ddev import-db -f .dbdump/ + ddev fetch-files + ``` + + `fetch-db` creates a new database dump file in `.dbdump`. + Check the content of that directory for available dump files. + Use an appropriate one for `` in the command shown above. + +6. Reset cache config and admin password + + ```sh + ddev drush cim -y + ddev drush cr + ddev drush upwd admin admin + ``` + +7. Access the site + + ```sh + ddev launch + ``` + + Use user `admin` with password `admin` to login as site administrator. + +## Related documentations + +* [DDEV](https://ddev.readthedocs.io/) +* [Drupal User Guide](https://www.drupal.org/docs/user_guide/en/index.html) + +[ddev]: https://ddev.com/