From 6fb8f2d654338a51cc2ef415072a78c07004b875 Mon Sep 17 00:00:00 2001 From: Tim Bolender Date: Tue, 14 Apr 2020 17:23:27 +0200 Subject: [PATCH 01/11] Do not use file system volume for sites --- installation/docker-compose-custom.yml | 15 ++++++++------- installation/docker-compose-erpnext.yml | 15 ++++++++------- installation/docker-compose-frappe.yml | 15 ++++++++------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/installation/docker-compose-custom.yml b/installation/docker-compose-custom.yml index 5a7c3696..67833600 100644 --- a/installation/docker-compose-custom.yml +++ b/installation/docker-compose-custom.yml @@ -28,7 +28,7 @@ services: - frappe-worker-long - frappe-worker-short volumes: - - ./sites:/var/www/html/sites:rw + - sites-vol:/var/www/html/sites:rw - assets-vol:/assets:rw [app]-python: @@ -44,7 +44,7 @@ services: - REDIS_SOCKETIO=redis-socketio:6379 - SOCKETIO_PORT=9000 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 frappe-socketio: @@ -55,7 +55,7 @@ services: links: - redis-socketio volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-default: image: [app]-worker @@ -68,7 +68,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-short: image: [app]-worker @@ -83,7 +83,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-long: image: [app]-worker @@ -98,7 +98,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-schedule: image: [app]-worker @@ -111,7 +111,8 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw volumes: assets-vol: + sites-vol: diff --git a/installation/docker-compose-erpnext.yml b/installation/docker-compose-erpnext.yml index 8e2cbd9e..cecea14d 100644 --- a/installation/docker-compose-erpnext.yml +++ b/installation/docker-compose-erpnext.yml @@ -25,7 +25,7 @@ services: - frappe-worker-long - frappe-worker-short volumes: - - ./sites:/var/www/html/sites:rw + - sites-vol:/var/www/html/sites:rw - assets-vol:/assets:rw erpnext-python: @@ -39,7 +39,7 @@ services: - SOCKETIO_PORT=9000 - AUTO_MIGRATE=1 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 frappe-socketio: @@ -50,7 +50,7 @@ services: links: - redis-socketio volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-default: image: frappe/erpnext-worker:${VERSION} @@ -63,7 +63,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-short: image: frappe/erpnext-worker:${VERSION} @@ -78,7 +78,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-long: image: frappe/erpnext-worker:${VERSION} @@ -93,7 +93,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-schedule: image: frappe/erpnext-worker:${VERSION} @@ -106,7 +106,8 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw volumes: assets-vol: + sites-vol: diff --git a/installation/docker-compose-frappe.yml b/installation/docker-compose-frappe.yml index f8365225..da44298f 100644 --- a/installation/docker-compose-frappe.yml +++ b/installation/docker-compose-frappe.yml @@ -25,7 +25,7 @@ services: - frappe-worker-long - frappe-worker-short volumes: - - ./sites:/var/www/html/sites:rw + - sites-vol:/var/www/html/sites:rw - assets-vol:/assets:rw frappe-python: @@ -39,7 +39,7 @@ services: - SOCKETIO_PORT=9000 - AUTO_MIGRATE=1 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 frappe-socketio: @@ -50,7 +50,7 @@ services: links: - redis-socketio volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-default: image: frappe/frappe-worker:${VERSION} @@ -63,7 +63,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-short: image: frappe/frappe-worker:${VERSION} @@ -78,7 +78,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-worker-long: image: frappe/frappe-worker:${VERSION} @@ -93,7 +93,7 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw frappe-schedule: image: frappe/frappe-worker:${VERSION} @@ -106,7 +106,8 @@ services: - redis-queue - redis-cache volumes: - - ./sites:/home/frappe/frappe-bench/sites:rw + - sites-vol:/home/frappe/frappe-bench/sites:rw volumes: assets-vol: + sites-vol: From 3772d580cc1896de30edde6d1b19e6c2324900df Mon Sep 17 00:00:00 2001 From: Tim Bolender Date: Tue, 14 Apr 2020 17:40:43 +0200 Subject: [PATCH 02/11] Remove obsolete instruction --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 0f090c8f..a38a7db0 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,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: From 3ed66d833323b071b092656517f76ea823e33c0c Mon Sep 17 00:00:00 2001 From: Tim Bolender Date: Mon, 20 Apr 2020 11:05:51 +0200 Subject: [PATCH 03/11] Add volumes to container description --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a38a7db0..8376294f 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,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 @@ -165,13 +165,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*. @@ -458,4 +464,4 @@ This repository includes a complete setup to develop with Frappe/ERPNext and Ben - VSCode Python debugger - Pre-configured Docker containers for an easy start -A complete Readme is available in [development/README.md](development/README.md) \ No newline at end of file +A complete Readme is available in [development/README.md](development/README.md) From 16cc6baf4c1d12b24fd956af472af4a1aab876d8 Mon Sep 17 00:00:00 2001 From: Tim Bolender Date: Mon, 20 Apr 2020 11:11:38 +0200 Subject: [PATCH 04/11] Use sites volume in all commands --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8376294f..9018eeb3 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,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 \ @@ -230,7 +230,7 @@ docker exec -it \ _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 @@ -250,7 +250,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 sites-vol:/home/frappe/frappe-bench/sites \ --network _default \ frappe/frappe-worker:v12 push-backup ``` @@ -308,7 +308,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 sites-vol:/home/frappe/frappe-bench/sites \ -v ./backups:/home/frappe/backups \ --network _default \ frappe/frappe-worker:v12 restore-backup From 529c23866f1c8f9b1ab101f990c2052f6f60da01 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Tue, 21 Apr 2020 14:59:06 +0530 Subject: [PATCH 05/11] fix(frappe-nginx): fix connection message --- build/frappe-nginx/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/frappe-nginx/docker-entrypoint.sh b/build/frappe-nginx/docker-entrypoint.sh index aec5b0aa..c1caad54 100755 --- a/build/frappe-nginx/docker-entrypoint.sh +++ b/build/frappe-nginx/docker-entrypoint.sh @@ -40,8 +40,8 @@ envsubst '${API_HOST} echo "Waiting for frappe-python to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_PY $FRAPPE_PY_PORT echo "Frappe-python available on $FRAPPE_PY port $FRAPPE_PY_PORT" -echo "Waiting for frappe-socketio to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" +echo "Waiting for frappe-socketio to be available on $FRAPPE_SOCKETIO port $SOCKETIO_PORT" timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_SOCKETIO $SOCKETIO_PORT -echo "Frappe-socketio available on $FRAPPE_PY port $FRAPPE_PY_PORT" +echo "Frappe-socketio available on $FRAPPE_SOCKETIO port $SOCKETIO_PORT" exec "$@" From 00165a240a5ce8e99a40b582330f0394cc7e7661 Mon Sep 17 00:00:00 2001 From: Tim Bolender Date: Wed, 22 Apr 2020 10:53:37 +0200 Subject: [PATCH 06/11] Fixed command line volume usage --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9018eeb3..90b79a8c 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,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 sites-vol:/home/frappe/frappe-bench/sites \ + -v _sites-vol:/home/frappe/frappe-bench/sites \ --network _default \ frappe/frappe-worker:v12 push-backup ``` @@ -308,7 +308,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 sites-vol:/home/frappe/frappe-bench/sites \ + -v _sites-vol:/home/frappe/frappe-bench/sites \ -v ./backups:/home/frappe/backups \ --network _default \ frappe/frappe-worker:v12 restore-backup From b633ea05decea82e44786c3bb4dc0dd7f511522a Mon Sep 17 00:00:00 2001 From: Tim Bolender Date: Wed, 22 Apr 2020 11:11:15 +0200 Subject: [PATCH 07/11] Instruct usage of RDS --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 90b79a8c..9052a206 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,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 _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: From 2d928049b5cc779963bfa58c97812dc2fb0d7fbe Mon Sep 17 00:00:00 2001 From: resourcefactor <63051249+resourcefactor@users.noreply.github.com> Date: Wed, 22 Apr 2020 16:19:37 +0400 Subject: [PATCH 08/11] Update README.md --- development/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/README.md b/development/README.md index 373ea1fd..d6a988ce 100644 --- a/development/README.md +++ b/development/README.md @@ -2,7 +2,7 @@ ## Prerequisites -In order to start deveping you need to satisfy the folowing prerequisites: +In order to start developing you need to satisfy the folowing prerequisites: - Docker - docker-compose From 7c917182802353f3e1eac496b170efdab0e2d1fd Mon Sep 17 00:00:00 2001 From: resourcefactor <63051249+resourcefactor@users.noreply.github.com> Date: Wed, 22 Apr 2020 16:20:44 +0400 Subject: [PATCH 09/11] Update README.md --- development/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/README.md b/development/README.md index 373ea1fd..381308e4 100644 --- a/development/README.md +++ b/development/README.md @@ -2,7 +2,7 @@ ## Prerequisites -In order to start deveping you need to satisfy the folowing prerequisites: +In order to start deveping you need to satisfy the following prerequisites: - Docker - docker-compose From 4f411104f3fbd88446eccb3cde19726a9435491b Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 23 Apr 2020 14:56:46 +0530 Subject: [PATCH 10/11] fix(frappe-nginx): Generate Standard Style CSS use nunjucks to render jinja2 template generate default theme --- build/frappe-nginx/Dockerfile | 12 +++++++++++- build/frappe-nginx/generate_standard_style_css.js | 14 ++++++++++++++ build/frappe-nginx/v12.Dockerfile | 12 +++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 build/frappe-nginx/generate_standard_style_css.js diff --git a/build/frappe-nginx/Dockerfile b/build/frappe-nginx/Dockerfile index 6fa6441a..a4684140 100644 --- a/build/frappe-nginx/Dockerfile +++ b/build/frappe-nginx/Dockerfile @@ -6,13 +6,23 @@ RUN mkdir -p /home/frappe/frappe-bench/sites \ RUN install_packages git -RUN mkdir -p apps sites/assets \ +RUN mkdir -p apps sites/assets/css \ && cd apps \ && git clone --depth 1 https://github.com/frappe/frappe +COPY build/frappe-nginx/generate_standard_style_css.js \ + /home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js + RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ + && yarn add nunjucks -D \ + && node generate_standard_style_css.js \ + frappe/website/doctype/website_theme/website_theme_template.scss > \ + /home/frappe/standard_templates_string \ + && node generate_bootstrap_theme.js \ + /home/frappe/frappe-bench/sites/assets/css/standard_style.css \ + "$(cat /home/frappe/standard_templates_string)" \ && rm -fr node_modules \ && yarn install --production=true \ && node --version \ diff --git a/build/frappe-nginx/generate_standard_style_css.js b/build/frappe-nginx/generate_standard_style_css.js new file mode 100644 index 00000000..275ab47d --- /dev/null +++ b/build/frappe-nginx/generate_standard_style_css.js @@ -0,0 +1,14 @@ +const nunjucks = require("nunjucks"); + +const templatePath = process.argv[2]; +const pathArray = templatePath.split("/"); +const templateFile = pathArray.pop(); +const templateDir = pathArray.join("/"); + +nunjucks.configure(templateDir); +const rendered = nunjucks.render(templateFile, { + button_rounded_corners: true, + font_properties: "300,600", +}); + +console.log(rendered.replace(/\n/gm, "\\n")); diff --git a/build/frappe-nginx/v12.Dockerfile b/build/frappe-nginx/v12.Dockerfile index c1860a2a..f9839d66 100644 --- a/build/frappe-nginx/v12.Dockerfile +++ b/build/frappe-nginx/v12.Dockerfile @@ -6,13 +6,23 @@ RUN mkdir -p /home/frappe/frappe-bench/sites \ RUN install_packages git -RUN mkdir -p apps sites/assets \ +RUN mkdir -p apps sites/assets/css \ && cd apps \ && git clone --depth 1 https://github.com/frappe/frappe --branch version-12 +COPY build/frappe-nginx/generate_standard_style_css.js \ + /home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js + RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ + && yarn add nunjucks -D \ + && node generate_standard_style_css.js \ + frappe/website/doctype/website_theme/website_theme_template.scss > \ + /home/frappe/standard_templates_string \ + && node generate_bootstrap_theme.js \ + /home/frappe/frappe-bench/sites/assets/css/standard_style.css \ + "$(cat /home/frappe/standard_templates_string)" \ && rm -fr node_modules \ && yarn install --production=true \ && node --version \ From 7599252a6274ac12d2ae3518a358d457476bfe7f Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 23 Apr 2020 21:56:52 +0530 Subject: [PATCH 11/11] revert(frappe-nginx): revert v12.Dockerfile standard_style.css generation not required for v12 --- build/frappe-nginx/v12.Dockerfile | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/build/frappe-nginx/v12.Dockerfile b/build/frappe-nginx/v12.Dockerfile index f9839d66..c883ea4e 100644 --- a/build/frappe-nginx/v12.Dockerfile +++ b/build/frappe-nginx/v12.Dockerfile @@ -6,23 +6,13 @@ RUN mkdir -p /home/frappe/frappe-bench/sites \ RUN install_packages git -RUN mkdir -p apps sites/assets/css \ +RUN mkdir -p apps sites/assets \ && cd apps \ && git clone --depth 1 https://github.com/frappe/frappe --branch version-12 -COPY build/frappe-nginx/generate_standard_style_css.js \ - /home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js - RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ - && yarn add nunjucks -D \ - && node generate_standard_style_css.js \ - frappe/website/doctype/website_theme/website_theme_template.scss > \ - /home/frappe/standard_templates_string \ - && node generate_bootstrap_theme.js \ - /home/frappe/frappe-bench/sites/assets/css/standard_style.css \ - "$(cat /home/frappe/standard_templates_string)" \ && rm -fr node_modules \ && yarn install --production=true \ && node --version \ @@ -49,4 +39,4 @@ RUN apt-get update && apt-get install -y rsync && apt-get clean \ VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["nginx", "-g", "daemon off;"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file