Merge pull request #195 from tbolender/sites-volume

Use Docker volumes for storing sites
This commit is contained in:
Revant Nandgaonkar
2020-04-22 18:43:27 +05:30
committed by GitHub
4 changed files with 51 additions and 33 deletions

View File

@@ -36,12 +36,6 @@ Copy the example docker environment file to `.env`:
cp installation/env-example installation/.env
```
Make a directory for sites:
```sh
mkdir installation/sites
```
### Setup Environment Variables
To get started, copy the existing `env-example` file to `.env` inside the `installation` directory. By default, the file will contain the following variables:
@@ -152,6 +146,21 @@ Notes:
- Use `docker-compose-frappe.yml` in case you need only Frappe without ERPNext.
- New site (first site) needs to be added after starting the services.
#### Using Amazon RDS (or any other DBaaS)
To configure usage of RDS, `common_site_config.json` in your `sites-vol` volume has to be edited using:
```sh
docker run \
-it \
-v <project-name>_sites-vol:/sites \
alpine vi /sites/common_site_config.json
```
Instead of `alpine` you can use any image you like.
For full instructions, refer to the [wiki](https://github.com/frappe/frappe/wiki/Using-Frappe-with-Amazon-RDS-(or-any-other-DBaaS). Common question can be found in Issues and on forum.
### Docker containers
This repository contains the following docker-compose files, each one containing the described images:
@@ -166,7 +175,7 @@ This repository contains the following docker-compose files, each one containing
* volume: mariadb-vol
* docker-compose-erpnext.yml
* erpnext-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port.
* volume: assets
* volume: assets-vol
* erpnext-python: main application code
* frappe-socketio: enables realtime communication to the user interface through websockets
* frappe-worker-default: background runner
@@ -176,13 +185,19 @@ This repository contains the following docker-compose files, each one containing
* docker-compose-frappe.yml
* frappe-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port.
* volume: assets
* volume: assets-vol, sites-vol
* erpnext-python: main application code
* volume: sites-vol
* frappe-socketio: enables realtime communication to the user interface through websockets
* volume: sites-vol
* frappe-worker-default: background runner
* volume: sites-vol
* frappe-worker-short: background runner for short-running jobs
* volume: sites-vol
* frappe-worker-long: background runner for long-running jobs
* volume: sites-vol
* frappe-schedule
* volume: sites-vol
* docker-compose-networks.yml: this yaml define the network to communicate with *Letsencrypt Nginx Proxy Companion*.
@@ -228,7 +243,7 @@ Environment Variables
- `WITH_FILES` if set to 1, it will backup user-uploaded files.
- By default `backup` takes mariadb dump and gzips it. Example file, `20200325_221230-test_localhost-database.sql.gz`
- If `WITH_FILES` is set then it will also backup public and private files of each site as uncompressed tarball. Example files, `20200325_221230-test_localhost-files.tar` and `20200325_221230-test_localhost-private-files.tar`
- All the files generated by backup are placed at volume location `sites/{site-name}/private/backups/*`
- All the files generated by backup are placed at volume location `sites-vol:/{site-name}/private/backups/*`
```sh
docker exec -it \
@@ -237,7 +252,7 @@ docker exec -it \
<project-name>_erpnext-python_1 docker-entrypoint.sh backup
```
The backup will be available in the `sites` mounted volume.
The backup will be available in the `sites-vol` volume.
#### Push backup to s3 compatible storage
@@ -257,7 +272,7 @@ Environment Variables
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \
-e "ENDPOINT_URL=https://region.storage-provider.com" \
-e "BUCKET_DIR=frappe-bench-v12" \
-v ./installation/sites:/home/frappe/frappe-bench/sites \
-v <project-name>_sites-vol:/home/frappe/frappe-bench/sites \
--network <project-name>_default \
frappe/frappe-worker:v12 push-backup
```
@@ -315,7 +330,7 @@ docker run \
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \
-e "ENDPOINT_URL=https://region.storage-provider.com" \
-e "BUCKET_DIR=frappe-bench-v12" \
-v ./installation/sites:/home/frappe/frappe-bench/sites \
-v <project-name>_sites-vol:/home/frappe/frappe-bench/sites \
-v ./backups:/home/frappe/backups \
--network <project-name>_default \
frappe/frappe-worker:v12 restore-backup