Skip to content

Commit

Permalink
Merge pull request #4 from swiss-artg/local_dev
Browse files Browse the repository at this point in the history
Local Development Environment
  • Loading branch information
corvus-ch authored Nov 26, 2024
2 parents 373881f + 0f78453 commit 11a0e63
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
Empty file added .dbdumps/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions .ddev/commands/web/fetch-db
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 14 additions & 0 deletions .ddev/commands/web/fetch-files
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ timezone: Europe/Zurich
composer_version: "2"
web_environment: []
corepack_enable: true
webimage_extra_packages:
- rclone
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@

# Ignore multi-site test environment.
/web/sites/simpletest

# Ignore ddev secrets
/.ddev/.env

# DB dump directory
!/.dbdump/.gitkeep
/.dbdump/*
106 changes: 106 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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=<host>
REMOTE_DB=<db>
REMOTE_DB_USER=<db_user>
REMOTE_DB_PASSWORD=<db_password>
REMOTE_FTP_USER=<ftp_user>
REMOTE_FTP_PASSWORD=<ftp_password>
REMOTE_FTP_PORT=<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/<dumpfile>
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 `<dumpfile>` 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/

0 comments on commit 11a0e63

Please sign in to comment.