2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-08 14:21:05 +00:00

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
commit 974f7dd74c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 cp installation/env-example installation/.env
``` ```
Make a directory for sites:
```sh
mkdir installation/sites
```
### Setup Environment Variables ### 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: 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. - 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. - 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 ### Docker containers
This repository contains the following docker-compose files, each one containing the described images: 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 * volume: mariadb-vol
* docker-compose-erpnext.yml * 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. * 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 * erpnext-python: main application code
* frappe-socketio: enables realtime communication to the user interface through websockets * frappe-socketio: enables realtime communication to the user interface through websockets
* frappe-worker-default: background runner * frappe-worker-default: background runner
@ -176,13 +185,19 @@ This repository contains the following docker-compose files, each one containing
* docker-compose-frappe.yml * 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. * 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 * erpnext-python: main application code
* volume: sites-vol
* frappe-socketio: enables realtime communication to the user interface through websockets * frappe-socketio: enables realtime communication to the user interface through websockets
* volume: sites-vol
* frappe-worker-default: background runner * frappe-worker-default: background runner
* volume: sites-vol
* frappe-worker-short: background runner for short-running jobs * frappe-worker-short: background runner for short-running jobs
* volume: sites-vol
* frappe-worker-long: background runner for long-running jobs * frappe-worker-long: background runner for long-running jobs
* volume: sites-vol
* frappe-schedule * frappe-schedule
* volume: sites-vol
* docker-compose-networks.yml: this yaml define the network to communicate with *Letsencrypt Nginx Proxy Companion*. * 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. - `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` - 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` - 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 ```sh
docker exec -it \ docker exec -it \
@ -237,7 +252,7 @@ docker exec -it \
<project-name>_erpnext-python_1 docker-entrypoint.sh backup <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 #### Push backup to s3 compatible storage
@ -257,7 +272,7 @@ Environment Variables
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \ -e "SECRET_ACCESS_KEY=secret_access_from_provider" \
-e "ENDPOINT_URL=https://region.storage-provider.com" \ -e "ENDPOINT_URL=https://region.storage-provider.com" \
-e "BUCKET_DIR=frappe-bench-v12" \ -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 \ --network <project-name>_default \
frappe/frappe-worker:v12 push-backup frappe/frappe-worker:v12 push-backup
``` ```
@ -315,7 +330,7 @@ docker run \
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \ -e "SECRET_ACCESS_KEY=secret_access_from_provider" \
-e "ENDPOINT_URL=https://region.storage-provider.com" \ -e "ENDPOINT_URL=https://region.storage-provider.com" \
-e "BUCKET_DIR=frappe-bench-v12" \ -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 \ -v ./backups:/home/frappe/backups \
--network <project-name>_default \ --network <project-name>_default \
frappe/frappe-worker:v12 restore-backup frappe/frappe-worker:v12 restore-backup

View File

@ -28,7 +28,7 @@ services:
- frappe-worker-long - frappe-worker-long
- frappe-worker-short - frappe-worker-short
volumes: volumes:
- ./sites:/var/www/html/sites:rw - sites-vol:/var/www/html/sites:rw
- assets-vol:/assets:rw - assets-vol:/assets:rw
[app]-python: [app]-python:
@ -44,7 +44,7 @@ services:
- REDIS_SOCKETIO=redis-socketio:6379 - REDIS_SOCKETIO=redis-socketio:6379
- SOCKETIO_PORT=9000 - SOCKETIO_PORT=9000
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
- assets-vol:/home/frappe/frappe-bench/sites/assets:rw - assets-vol:/home/frappe/frappe-bench/sites/assets:rw
frappe-socketio: frappe-socketio:
@ -55,7 +55,7 @@ services:
links: links:
- redis-socketio - redis-socketio
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-default: frappe-worker-default:
image: [app]-worker image: [app]-worker
@ -68,7 +68,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-short: frappe-worker-short:
image: [app]-worker image: [app]-worker
@ -83,7 +83,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-long: frappe-worker-long:
image: [app]-worker image: [app]-worker
@ -98,7 +98,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-schedule: frappe-schedule:
image: [app]-worker image: [app]-worker
@ -111,7 +111,8 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
volumes: volumes:
assets-vol: assets-vol:
sites-vol:

View File

@ -25,7 +25,7 @@ services:
- frappe-worker-long - frappe-worker-long
- frappe-worker-short - frappe-worker-short
volumes: volumes:
- ./sites:/var/www/html/sites:rw - sites-vol:/var/www/html/sites:rw
- assets-vol:/assets:rw - assets-vol:/assets:rw
erpnext-python: erpnext-python:
@ -39,7 +39,7 @@ services:
- SOCKETIO_PORT=9000 - SOCKETIO_PORT=9000
- AUTO_MIGRATE=1 - AUTO_MIGRATE=1
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
- assets-vol:/home/frappe/frappe-bench/sites/assets:rw - assets-vol:/home/frappe/frappe-bench/sites/assets:rw
frappe-socketio: frappe-socketio:
@ -50,7 +50,7 @@ services:
links: links:
- redis-socketio - redis-socketio
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-default: frappe-worker-default:
image: frappe/erpnext-worker:${VERSION} image: frappe/erpnext-worker:${VERSION}
@ -63,7 +63,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-short: frappe-worker-short:
image: frappe/erpnext-worker:${VERSION} image: frappe/erpnext-worker:${VERSION}
@ -78,7 +78,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-long: frappe-worker-long:
image: frappe/erpnext-worker:${VERSION} image: frappe/erpnext-worker:${VERSION}
@ -93,7 +93,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-schedule: frappe-schedule:
image: frappe/erpnext-worker:${VERSION} image: frappe/erpnext-worker:${VERSION}
@ -106,7 +106,8 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
volumes: volumes:
assets-vol: assets-vol:
sites-vol:

View File

@ -25,7 +25,7 @@ services:
- frappe-worker-long - frappe-worker-long
- frappe-worker-short - frappe-worker-short
volumes: volumes:
- ./sites:/var/www/html/sites:rw - sites-vol:/var/www/html/sites:rw
- assets-vol:/assets:rw - assets-vol:/assets:rw
frappe-python: frappe-python:
@ -39,7 +39,7 @@ services:
- SOCKETIO_PORT=9000 - SOCKETIO_PORT=9000
- AUTO_MIGRATE=1 - AUTO_MIGRATE=1
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
- assets-vol:/home/frappe/frappe-bench/sites/assets:rw - assets-vol:/home/frappe/frappe-bench/sites/assets:rw
frappe-socketio: frappe-socketio:
@ -50,7 +50,7 @@ services:
links: links:
- redis-socketio - redis-socketio
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-default: frappe-worker-default:
image: frappe/frappe-worker:${VERSION} image: frappe/frappe-worker:${VERSION}
@ -63,7 +63,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-short: frappe-worker-short:
image: frappe/frappe-worker:${VERSION} image: frappe/frappe-worker:${VERSION}
@ -78,7 +78,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-worker-long: frappe-worker-long:
image: frappe/frappe-worker:${VERSION} image: frappe/frappe-worker:${VERSION}
@ -93,7 +93,7 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
frappe-schedule: frappe-schedule:
image: frappe/frappe-worker:${VERSION} image: frappe/frappe-worker:${VERSION}
@ -106,7 +106,8 @@ services:
- redis-queue - redis-queue
- redis-cache - redis-cache
volumes: volumes:
- ./sites:/home/frappe/frappe-bench/sites:rw - sites-vol:/home/frappe/frappe-bench/sites:rw
volumes: volumes:
assets-vol: assets-vol:
sites-vol: