From be8f0e4fa0777a6b9149944b29b3ec889032fe63 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 6 Mar 2020 06:12:11 +0000 Subject: [PATCH] rudimentary docs --- README.md | 57 ++++++++++++ installation/docker-compose-custom.yml | 117 +++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 installation/docker-compose-custom.yml diff --git a/README.md b/README.md index bef76892..bbc93b1c 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,63 @@ docker exec -it \ _erpnext-python_1 docker-entrypoint.sh migrate ``` +### Custom apps + +> For the sake of example, we'll be using a place holder called `[custom]`, and we'll be building off the edge image. + +To add your own apps to the image, we'll need to create a custom image with the help of a special wrapper script + +1. Create two folders called `[custom]-worker` and `[custom]-assets` in the `build` folder. + + ```bash + cd frappe_docker + mkdir ./build/[custom]-worker ./build/[custom]-assets + ``` + +2. Create a `Dockerfile` in `./build/[custom]-worker` with the following content: + + ```Dockerfile + FROM frappe/erpnext-worker:edge + + RUN install_app [custom] https://github.com/[username]/[custom] [branch] + # Only add the branch if you are using a specific tag or branch. + ``` + +3. Create a `Dockerfile` in `./build/[custom]-assets` with the following content: + + ```Dockerfile + FROM bitnami/node:12-prod + + COPY build/[custom]-assets/install_app.sh /install_app + + RUN /install_app [custom] https://github.com/[username]/[custom] + + FROM frappe/erpnext-assets:edge + + COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ + COPY --from=0 /rsync /rsync + RUN echo -n "\nerpnext" >> /var/www/html/apps.txt + + VOLUME [ "/assets" ] + + ENTRYPOINT ["/docker-entrypoint.sh"] + CMD ["nginx", "-g", "daemon off;"] + ``` + +4. Copy over the `install_app.sh` file from `./build/erpnext-assets` + + ```bash + cp ./build/erpnext-assets/install.sh ./build/[custom]-assets + ``` + +5. Open up `./installation/docker-compose-custom.yml` and replace all instances of `[app]` with the name of your app. + + ```bash + sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml + ``` + +6. Install like usuall, except that when you set the `INSTALL_APPS` variable set it to `erpnext,[custom]`. + ### Troubleshoot 1. Remove containers and volumes, and clear redis cache: diff --git a/installation/docker-compose-custom.yml b/installation/docker-compose-custom.yml new file mode 100644 index 00000000..5a7c3696 --- /dev/null +++ b/installation/docker-compose-custom.yml @@ -0,0 +1,117 @@ +version: '3' + +services: + [app]-assets: + image: [app]-assets + build: + context: . + dockerfile: ./build/[app]-assets/Dockerfile + restart: on-failure + environment: + - FRAPPE_PY=erpnext-python + - FRAPPE_PY_PORT=8000 + - FRAPPE_SOCKETIO=frappe-socketio + - SOCKETIO_PORT=9000 + - LETSENCRYPT_HOST=${SITES} + - VIRTUAL_HOST=${SITES} + - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} + depends_on: + - [app]-python + - frappe-socketio + - frappe-worker-default + - frappe-worker-long + - frappe-worker-short + links: + - [app]-python + - frappe-socketio + - frappe-worker-default + - frappe-worker-long + - frappe-worker-short + volumes: + - ./sites:/var/www/html/sites:rw + - assets-vol:/assets:rw + + [app]-python: + image: [app]-worker + build: + context: . + dockerfile: ./build/[app]-worker/Dockerfile + restart: on-failure + environment: + - MARIADB_HOST=${MARIADB_HOST} + - REDIS_CACHE=redis-cache:6379 + - REDIS_QUEUE=redis-queue:6379 + - REDIS_SOCKETIO=redis-socketio:6379 + - SOCKETIO_PORT=9000 + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + - assets-vol:/home/frappe/frappe-bench/sites/assets:rw + + frappe-socketio: + image: frappe/frappe-socketio:${VERSION} + restart: on-failure + depends_on: + - redis-socketio + links: + - redis-socketio + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-worker-default: + image: [app]-worker + restart: on-failure + command: worker + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-worker-short: + image: [app]-worker + restart: on-failure + command: worker + environment: + - WORKER_TYPE=short + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-worker-long: + image: [app]-worker + restart: on-failure + command: worker + environment: + - WORKER_TYPE=long + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-schedule: + image: [app]-worker + restart: on-failure + command: schedule + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + +volumes: + assets-vol: