docs: organize docs
break down readme into multiple files organize in docs directory [skip travis]
This commit is contained in:
56
docs/custom-apps-for-production.md
Normal file
56
docs/custom-apps-for-production.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Custom apps
|
||||
|
||||
To add your own Frappe/ERPNext apps to the image, we'll need to create a custom image with the help of a unique wrapper script
|
||||
|
||||
> For the sake of simplicity, in this example, we'll be using a place holder called `[custom]`, and we'll be building off the edge image.
|
||||
|
||||
Create two directories called `[custom]-worker` and `[custom]-nginx` in the `build` directory.
|
||||
|
||||
```shell
|
||||
cd frappe_docker
|
||||
mkdir ./build/[custom]-worker ./build/[custom]-nginx
|
||||
```
|
||||
|
||||
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.
|
||||
```
|
||||
|
||||
Create a `Dockerfile` in `./build/[custom]-nginx` with the following content:
|
||||
|
||||
```Dockerfile
|
||||
FROM bitnami/node:12-prod
|
||||
|
||||
COPY build/[custom]-nginx/install_app.sh /install_app
|
||||
|
||||
RUN /install_app [custom] https://github.com/[username]/[custom]
|
||||
|
||||
FROM frappe/erpnext-nginx:edge
|
||||
|
||||
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
|
||||
COPY --from=0 /rsync /rsync
|
||||
RUN echo -n "\n[custom]" >> /var/www/html/apps.txt
|
||||
|
||||
VOLUME [ "/assets" ]
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
```
|
||||
|
||||
Copy over the `install_app.sh` file from `./build/erpnext-nginx`
|
||||
|
||||
```shell
|
||||
cp ./build/erpnext-nginx/install.sh ./build/[custom]-nginx
|
||||
```
|
||||
|
||||
Open up `./installation/docker-compose-custom.yml` and replace all instances of `[app]` with the name of your app.
|
||||
|
||||
```shell
|
||||
sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml
|
||||
```
|
||||
|
||||
Install like usual, except that when you set the `INSTALL_APPS` variable to `erpnext,[custom]`.
|
||||
479
docs/docker-swarm.md
Normal file
479
docs/docker-swarm.md
Normal file
@@ -0,0 +1,479 @@
|
||||
### Prerequisites
|
||||
|
||||
IMPORTANT: All commands are executed on live server with public IP and DNS Configured.
|
||||
|
||||
#### Setup docker swarm
|
||||
|
||||
Set hostname
|
||||
|
||||
```shell
|
||||
export USE_HOSTNAME=dog.example.com
|
||||
|
||||
echo $USE_HOSTNAME > /etc/hostname
|
||||
hostname -F /etc/hostname
|
||||
```
|
||||
|
||||
Update packages using tools provided by installed linux distribution.
|
||||
|
||||
Example on Ubuntu. Use distro specific commands.
|
||||
|
||||
```shell
|
||||
apt-get update -y && apt-get upgrade
|
||||
```
|
||||
|
||||
Install Docker using official convenience script
|
||||
|
||||
```shell
|
||||
# Download Docker
|
||||
curl -fsSL get.docker.com -o get-docker.sh
|
||||
# Install Docker using the stable channel (instead of the default "edge")
|
||||
CHANNEL=stable sh get-docker.sh
|
||||
# Remove Docker install script
|
||||
rm get-docker.sh
|
||||
```
|
||||
|
||||
Setup Swarm Mode
|
||||
|
||||
```shell
|
||||
docker swarm init --advertise-addr 111.111.111.111
|
||||
```
|
||||
|
||||
Note: Select the public IP of the server instead of 111.111.111.111
|
||||
|
||||
Add worker nodes. Execute following command from worker node.
|
||||
|
||||
```shell
|
||||
docker swarm join --token SWMTKN-1-5tl7ya98erd9qtasdfml4lqbosbhfqv3asdf4p13-dzw6ugasdfk0arn0 111.111.111.111:2377
|
||||
```
|
||||
|
||||
Note: Replace appropriate token and Public IP of manager in the command.
|
||||
|
||||
#### Install Traefik on manager node
|
||||
|
||||
Set environment variables
|
||||
|
||||
- `EMAIL=user@domain.com`: Letsencrypt Email
|
||||
- `DOMAIN`: Domain for traefik dashboard, e.g. traefik.example.com
|
||||
- `HASHED_PASSWORD=$(openssl passwd -apr1 $PASSWORD)` where `PASSWORD` is secret string
|
||||
|
||||
deploy the following yaml.
|
||||
|
||||
```shell
|
||||
docker stack deploy -c traefik.yaml traefik
|
||||
```
|
||||
|
||||
```yaml
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:v2.2
|
||||
ports:
|
||||
- target: 80
|
||||
published: 80
|
||||
mode: host
|
||||
- target: 443
|
||||
published: 443
|
||||
mode: host
|
||||
command:
|
||||
- --api
|
||||
- --log.level=INFO
|
||||
- --accesslog=true
|
||||
- --metrics.prometheus=true
|
||||
- --providers.docker=true
|
||||
- --providers.docker.endpoint=unix:///var/run/docker.sock
|
||||
- --providers.docker.swarmMode=true
|
||||
- --providers.docker.exposedbydefault=false
|
||||
- --providers.docker.network=traefik-public
|
||||
- --entrypoints.http.address=:80
|
||||
- --entrypoints.https.address=:443
|
||||
- --certificatesResolvers.certbot=true
|
||||
- --certificatesResolvers.certbot.acme.httpChallenge=true
|
||||
- --certificatesResolvers.certbot.acme.httpChallenge.entrypoint=http
|
||||
- --certificatesResolvers.certbot.acme.email=${EMAIL?Variable EMAIL not set}
|
||||
- --certificatesResolvers.certbot.acme.storage=/certs/acme-v2.json
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /data/traefik/certs:/certs
|
||||
networks:
|
||||
- traefik-public
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.role == manager
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
labels:
|
||||
# v2.2
|
||||
- "traefik.docker.network=traefik-public"
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
|
||||
# Http
|
||||
- "traefik.http.routers.traefik.rule=Host(`${DOMAIN?Variable DOMAIN not set}`)"
|
||||
- "traefik.http.routers.traefik.entrypoints=http,https"
|
||||
# Enable Let's encrypt auto certificat creation
|
||||
- "traefik.http.routers.traefik.tls.certresolver=certbot"
|
||||
# Enable authentification
|
||||
- "traefik.http.routers.traefik.middlewares=traefik-auth"
|
||||
- "traefik.http.middlewares.traefik-auth.basicauth.users=admin:${HASHED_PASSWORD?Variable HASHED_PASSWORD not set}"
|
||||
# Redirect All hosts to HTTPS
|
||||
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
|
||||
- "traefik.http.routers.http-catchall.entrypoints=http"
|
||||
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https@docker"
|
||||
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
|
||||
- "traefik.http.routers.traefik.service=api@internal"
|
||||
- "traefik.http.routers.traefik.tls"
|
||||
|
||||
networks:
|
||||
traefik-public:
|
||||
name: traefik-public
|
||||
attachable: true
|
||||
driver: overlay
|
||||
```
|
||||
|
||||
#### Install Portainer
|
||||
|
||||
Set environment variable `DOMAIN` as domain where portainer is located e.g. `DOMAIN=portainer.example.com`
|
||||
|
||||
deploy the following yaml.
|
||||
|
||||
```shell
|
||||
docker stack deploy -c portainer.yaml portainer
|
||||
```
|
||||
|
||||
```yaml
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
agent:
|
||||
image: portainer/agent:1.5.1
|
||||
environment:
|
||||
AGENT_CLUSTER_ADDR: tasks.agent
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /var/lib/docker/volumes:/var/lib/docker/volumes
|
||||
networks:
|
||||
- agent-network
|
||||
deploy:
|
||||
mode: global
|
||||
placement:
|
||||
constraints:
|
||||
- node.platform.os == linux
|
||||
|
||||
portainer:
|
||||
image: portainer/portainer:1.23.2
|
||||
command: -H tcp://tasks.agent:9001 --tlsskipverify
|
||||
volumes:
|
||||
- portainer-data:/data
|
||||
networks:
|
||||
- agent-network
|
||||
- traefik-public
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- node.role == manager
|
||||
- node.labels.portainer.portainer-data == true
|
||||
labels:
|
||||
- "traefik.docker.network=traefik-public"
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
|
||||
# Http
|
||||
- "traefik.http.routers.portainer.rule=Host(`${DOMAIN?Variable DOMAIN not set}`)"
|
||||
- "traefik.http.routers.portainer.entrypoints=http,https"
|
||||
# Enable Let's encrypt auto certificate creation
|
||||
- "traefik.http.routers.portainer.tls.certresolver=certbot"
|
||||
networks:
|
||||
agent-network:
|
||||
attachable: true
|
||||
traefik-public:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
portainer-data:
|
||||
```
|
||||
|
||||
Use Portainer for rest of the guide
|
||||
|
||||
### Create Config
|
||||
|
||||
Configs > Add Config > `frappe-mariadb-config`
|
||||
|
||||
```
|
||||
[mysqld]
|
||||
character-set-client-handshake = FALSE
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
```
|
||||
|
||||
### Create Secret
|
||||
|
||||
Secret > Add Secret > `frappe-mariadb-root-password`
|
||||
|
||||
```
|
||||
longsecretpassword
|
||||
```
|
||||
|
||||
Note down this password.
|
||||
It is only available in mariadb containers at location `/run/secrets/frappe-mariadb-root-password` later
|
||||
|
||||
### Deploy MariaDB Replication
|
||||
|
||||
Stacks > Add Stacks > `frappe-mariadb`
|
||||
|
||||
```yaml
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
mariadb-master:
|
||||
image: 'bitnami/mariadb:10.3'
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
configs:
|
||||
- source: frappe-mariadb-config
|
||||
target: /opt/bitnami/mariadb/conf/bitnami/my_custom.cnf
|
||||
networks:
|
||||
- frappe-network
|
||||
secrets:
|
||||
- frappe-mariadb-root-password
|
||||
volumes:
|
||||
- 'mariadb_master_data:/bitnami/mariadb'
|
||||
environment:
|
||||
- MARIADB_REPLICATION_MODE=master
|
||||
- MARIADB_REPLICATION_USER=repl_user
|
||||
- MARIADB_REPLICATION_PASSWORD_FILE=/run/secrets/frappe-mariadb-root-password
|
||||
- MARIADB_ROOT_PASSWORD_FILE=/run/secrets/frappe-mariadb-root-password
|
||||
|
||||
mariadb-slave:
|
||||
image: 'bitnami/mariadb:10.3'
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
configs:
|
||||
- source: frappe-mariadb-config
|
||||
target: /opt/bitnami/mariadb/conf/bitnami/my_custom.cnf
|
||||
networks:
|
||||
- frappe-network
|
||||
secrets:
|
||||
- frappe-mariadb-root-password
|
||||
volumes:
|
||||
- 'mariadb_slave_data:/bitnami/mariadb'
|
||||
environment:
|
||||
- MARIADB_REPLICATION_MODE=slave
|
||||
- MARIADB_REPLICATION_USER=repl_user
|
||||
- MARIADB_REPLICATION_PASSWORD_FILE=/run/secrets/frappe-mariadb-root-password
|
||||
- MARIADB_MASTER_HOST=mariadb-master
|
||||
- MARIADB_MASTER_PORT_NUMBER=3306
|
||||
- MARIADB_MASTER_ROOT_PASSWORD_FILE=/run/secrets/frappe-mariadb-root-password
|
||||
|
||||
volumes:
|
||||
mariadb_master_data:
|
||||
mariadb_slave_data:
|
||||
|
||||
configs:
|
||||
frappe-mariadb-config:
|
||||
external: true
|
||||
|
||||
secrets:
|
||||
frappe-mariadb-root-password:
|
||||
external: true
|
||||
|
||||
networks:
|
||||
frappe-network:
|
||||
name: frappe-network
|
||||
attachable: true
|
||||
```
|
||||
|
||||
### Deploy Frappe/ERPNext
|
||||
|
||||
Stacks > Add Stacks > `frappe-bench-v12`
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
redis-cache:
|
||||
image: redis:latest
|
||||
volumes:
|
||||
- redis-cache-vol:/data
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
redis-queue:
|
||||
image: redis:latest
|
||||
volumes:
|
||||
- redis-queue-vol:/data
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
redis-socketio:
|
||||
image: redis:latest
|
||||
volumes:
|
||||
- redis-socketio-vol:/data
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
erpnext-nginx:
|
||||
image: frappe/erpnext-nginx:v12.7.1
|
||||
environment:
|
||||
- FRAPPE_PY=erpnext-python
|
||||
- FRAPPE_PY_PORT=8000
|
||||
- FRAPPE_SOCKETIO=frappe-socketio
|
||||
- SOCKETIO_PORT=9000
|
||||
volumes:
|
||||
- sites-vol:/var/www/html/sites:rw
|
||||
- assets-vol:/assets:rw
|
||||
networks:
|
||||
- frappe-network
|
||||
- traefik-public
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
labels:
|
||||
- "traefik.docker.network=traefik-public"
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.services.frappe-bench-v12.loadbalancer.server.port=80"
|
||||
# Http
|
||||
- "traefik.http.routers.frappe-bench-v12.rule=Host(${SITES?Variable SITES not set})"
|
||||
- "traefik.http.routers.frappe-bench-v12.entrypoints=http,https"
|
||||
# Enable Let's encrypt auto certificate creation
|
||||
- "traefik.http.routers.frappe-bench-v12.tls.certresolver=certbot"
|
||||
|
||||
erpnext-python:
|
||||
image: frappe/erpnext-worker:v12.7.1
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
environment:
|
||||
- MARIADB_HOST=${MARIADB_HOST?Variable MARIADB_HOST not set}
|
||||
- REDIS_CACHE=redis-cache:6379
|
||||
- REDIS_QUEUE=redis-queue:6379
|
||||
- REDIS_SOCKETIO=redis-socketio:6379
|
||||
- SOCKETIO_PORT=9000
|
||||
- AUTO_MIGRATE=1
|
||||
volumes:
|
||||
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
||||
- assets-vol:/home/frappe/frappe-bench/sites/assets:rw
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
frappe-socketio:
|
||||
image: frappe/frappe-socketio:v12.5.1
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
volumes:
|
||||
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
frappe-worker-default:
|
||||
image: frappe/erpnext-worker:v12.7.1
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
command: worker
|
||||
volumes:
|
||||
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
frappe-worker-short:
|
||||
image: frappe/erpnext-worker:v12.7.1
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
command: worker
|
||||
environment:
|
||||
- WORKER_TYPE=short
|
||||
volumes:
|
||||
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
frappe-worker-long:
|
||||
image: frappe/erpnext-worker:v12.7.1
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
command: worker
|
||||
environment:
|
||||
- WORKER_TYPE=long
|
||||
volumes:
|
||||
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
frappe-schedule:
|
||||
image: frappe/erpnext-worker:v12.7.1
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
command: schedule
|
||||
volumes:
|
||||
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
volumes:
|
||||
redis-cache-vol:
|
||||
redis-queue-vol:
|
||||
redis-socketio-vol:
|
||||
assets-vol:
|
||||
sites-vol:
|
||||
|
||||
networks:
|
||||
traefik-public:
|
||||
external: true
|
||||
frappe-network:
|
||||
external: true
|
||||
```
|
||||
|
||||
Use environment variables:
|
||||
|
||||
- `MARIADB_HOST=frappe-mariadb_mariadb-master`
|
||||
- `SITES` variable is list of sites in back tick and separated by comma
|
||||
```
|
||||
SITES=`site1.example.com`,`site2.example.com`
|
||||
```
|
||||
|
||||
### Create new site job
|
||||
|
||||
1. Containers > Add Container > `add-site1-example-com`
|
||||
2. Select Image frappe/erpnext-worker:v12
|
||||
3. Set command as `new`
|
||||
4. Select network `frappe-network`
|
||||
5. Select Volume `frappe-bench-v12_sites_vol` and mount in container `/home/frappe/frappe-bench/sites`
|
||||
6. Env variables:
|
||||
- MYSQL_ROOT_PASSWORD=longsecretpassword
|
||||
- SITE_NAME=site1.example.com
|
||||
7. Start container
|
||||
|
||||
### Migrate Sites job
|
||||
|
||||
1. Containers > Add Container > `migrate-sites`
|
||||
2. Select Image frappe/erpnext-worker:v12
|
||||
3. Set command as `migrate`
|
||||
4. Select network `frappe-network`
|
||||
5. Select Volume `frappe-bench-v12_sites_vol` and mount in container `/home/frappe/frappe-bench/sites`
|
||||
6. Env variables:
|
||||
- MAINTENANCE_MODE=1
|
||||
7. Start container
|
||||
|
||||
194
docs/multi-bench.md
Normal file
194
docs/multi-bench.md
Normal file
@@ -0,0 +1,194 @@
|
||||
# Multi bench
|
||||
|
||||
This setup separates all services such that only required ones can be deployed.
|
||||
|
||||
This is suitable when multiple services are installed on cluster with shared proxy/router, database, cache etc.
|
||||
|
||||
Make sure you've cloned this repository and switch to the directory before executing following commands.
|
||||
|
||||
## Setup Environment Variables
|
||||
|
||||
Copy the example docker environment file to `.env`:
|
||||
|
||||
```sh
|
||||
cp env-example .env
|
||||
```
|
||||
|
||||
To get started, copy the existing `env-example` file to `.env`. By default, the file will contain the following variables:
|
||||
|
||||
- `VERSION=edge`
|
||||
- In this case, `edge` corresponds to `develop`. To setup any other version, you may use the branch name or version specific tags. (eg. version-12, v11.1.15, v11)
|
||||
- `MYSQL_ROOT_PASSWORD=admin`
|
||||
- Bootstraps a MariaDB container with this value set as the root password. If a managed MariaDB instance is used, there is no need to set the password here.
|
||||
- `MARIADB_HOST=mariadb`
|
||||
- Sets the hostname to `mariadb`. This is required if the database is managed by the containerized MariaDB instance.
|
||||
- In case of a separately managed database setups, set the value to the database's hostname/IP/domain.
|
||||
- `SITES=site1.domain.com,site2.domain.com`
|
||||
- List of sites that are part of the deployment "bench" Each site is separated by a comma(,).
|
||||
- If LetsEncrypt is being setup, make sure that the DNS for all the site's domains correctly point to the current instance.
|
||||
- `LETSENCRYPT_EMAIL=your.email@your.domain.com`
|
||||
- Email for LetsEncrypt expiry notification. This is only required if you are setting up LetsEncrypt.
|
||||
|
||||
Notes:
|
||||
|
||||
- docker-compose-erpnext.yml and docker-compose-frappe.yml set `AUTO_MIGRATE` environment variable to `1`.
|
||||
- `AUTO_MIGRATE` checks if there is semver bump or git hash change in case of develop branch and automatically migrates the sites on container start up.
|
||||
- It is good practice to use image tag for specific version instead of latest. e.g `frappe-socketio:v12.5.1`, `erpnext-nginx:v12.7.1`.
|
||||
|
||||
## Local deployment for testing
|
||||
|
||||
For trying out locally or to develop apps using ERPNext REST API port 80 must be published.
|
||||
Following command will start the needed containers and expose ports.
|
||||
|
||||
For Erpnext:
|
||||
|
||||
```sh
|
||||
docker-compose \
|
||||
--project-name <project-name> \
|
||||
-f installation/docker-compose-common.yml \
|
||||
-f installation/docker-compose-erpnext.yml \
|
||||
-f installation/erpnext-publish.yml \
|
||||
up -d
|
||||
```
|
||||
|
||||
For Frappe:
|
||||
|
||||
```sh
|
||||
docker-compose \
|
||||
--project-name <project-name> \
|
||||
-f installation/docker-compose-common.yml \
|
||||
-f installation/docker-compose-frappe.yml \
|
||||
-f installation/frappe-publish.yml \
|
||||
up -d
|
||||
```
|
||||
|
||||
Make sure to replace `<project-name>` with the desired name you wish to set for the project.
|
||||
|
||||
Notes:
|
||||
|
||||
- New site (first site) needs to be added after starting the services.
|
||||
- The local deployment is for testing and REST API development purpose only
|
||||
- A complete development environment is available [here](development)
|
||||
- The site names are limited to patterns matching \*.localhost by default
|
||||
- Additional site name patterns can be added by editing /etc/hosts of your host machine
|
||||
|
||||
## Deployment for production
|
||||
|
||||
### Setup Letsencrypt Nginx Proxy Companion
|
||||
|
||||
Letsencrypt Nginx Proxy Companion can optionally be setup to provide SSL. This is recommended for instances accessed over the internet.
|
||||
|
||||
Your DNS will need to be configured correctly for Letsencrypt to verify your domain.
|
||||
|
||||
To setup the proxy companion, run the following commands:
|
||||
|
||||
```sh
|
||||
cd $HOME
|
||||
git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git
|
||||
cd docker-compose-letsencrypt-nginx-proxy-companion
|
||||
cp .env.sample .env
|
||||
./start.sh
|
||||
```
|
||||
|
||||
It will create the required network and configure containers for Letencrypt ACME.
|
||||
|
||||
For more details, see the [Letsencrypt Nginx Proxy Companion github repo](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion). Letsencrypt Nginx Proxy Companion github repo works by automatically proxying to containers with the `VIRTUAL_HOST` environmental variable.
|
||||
|
||||
Notes:
|
||||
|
||||
- `SITES` variables from `env-example` is set as `VIRTUAL_HOST`
|
||||
- `LETSENCRYPT_EMAIL` variables from `env-example` is used as it is.
|
||||
- This is simple nginx + letsencrypt solution. Any other solution can be setup. Above two variables can be re-used or removed in case any other reverse-proxy is used.
|
||||
|
||||
### Start Frappe/ERPNext Services
|
||||
|
||||
To start the Frappe/ERPNext services for production, run the following command:
|
||||
|
||||
```sh
|
||||
docker-compose \
|
||||
--project-name <project-name> \
|
||||
-f installation/docker-compose-common.yml \
|
||||
-f installation/docker-compose-erpnext.yml \
|
||||
-f installation/docker-compose-networks.yml \
|
||||
up -d
|
||||
```
|
||||
|
||||
Make sure to replace `<project-name>` with any desired name you wish to set for the project.
|
||||
|
||||
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.
|
||||
|
||||
## Docker containers
|
||||
|
||||
This repository contains the following docker-compose files, each one containing the described images:
|
||||
* docker-compose-common.yml
|
||||
* redis-cache
|
||||
* volume: redis-cache-vol
|
||||
* redis-queue
|
||||
* volume: redis-queue-vol
|
||||
* redis-socketio
|
||||
* volume: redis-socketio-vol
|
||||
* mariadb: main database
|
||||
* 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-vol
|
||||
* erpnext-python: main application code
|
||||
* frappe-socketio: enables realtime communication to the user interface through websockets
|
||||
* frappe-worker-default: background runner
|
||||
* frappe-worker-short: background runner for short-running jobs
|
||||
* frappe-worker-long: background runner for long-running jobs
|
||||
* frappe-schedule
|
||||
|
||||
* 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-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*.
|
||||
|
||||
* erpnext-publish.yml: this yml extends erpnext-nginx service to publish port 80, can only be used with docker-compose-erpnext.yml
|
||||
|
||||
* frappe-publish.yml: this yml extends frappe-nginx service to publish port 80, can only be used with docker-compose-frappe.yml
|
||||
|
||||
## Updating and Migrating Sites
|
||||
|
||||
Switch to the root of the `frappe_docker` directory before running the following commands:
|
||||
|
||||
```sh
|
||||
# Update environment variable VERSION
|
||||
nano .env
|
||||
|
||||
# Pull new images
|
||||
docker-compose \
|
||||
-f installation/docker-compose-common.yml \
|
||||
-f installation/docker-compose-erpnext.yml \
|
||||
pull
|
||||
|
||||
# Restart containers
|
||||
docker-compose \
|
||||
--project-name <project-name> \
|
||||
-f installation/docker-compose-common.yml \
|
||||
-f installation/docker-compose-erpnext.yml \
|
||||
-f installation/docker-compose-networks.yml \
|
||||
up -d
|
||||
|
||||
docker run \
|
||||
-e "MAINTENANCE_MODE=1" \
|
||||
-v <project-name>_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
--network <project-name>_default \
|
||||
frappe/erpnext-worker:$VERSION migrate
|
||||
```
|
||||
111
docs/single-bench.md
Normal file
111
docs/single-bench.md
Normal file
@@ -0,0 +1,111 @@
|
||||
# Single Bench
|
||||
|
||||
This setup starts traefik service as part of single docker-compose project. It is quick to get started locally or on production for a single server with single deployment.
|
||||
|
||||
This is not suitable when multiple services are installed on cluster with shared proxy/router, database, cache etc.
|
||||
|
||||
Make sure you've cloned this repository and switch to the directory before executing following commands.
|
||||
|
||||
## Setup Environment Variables
|
||||
|
||||
Copy the example docker environment file to `.env`:
|
||||
|
||||
For local setup
|
||||
|
||||
```sh
|
||||
cp env-local .env
|
||||
```
|
||||
|
||||
For production
|
||||
|
||||
```sh
|
||||
cp env-production .env
|
||||
|
||||
```
|
||||
|
||||
To get started, copy the existing `env-local` or `env-production` file to `.env`. By default, the file will contain the following variables:
|
||||
|
||||
- `ERPNEXT_VERSION=edge`
|
||||
- In this case, `edge` corresponds to `develop`. To setup any other version, you may use the branch name or version specific tags. (eg. version-12, v11.1.15, v11).
|
||||
- `FRAPPE_VERSION=edge`
|
||||
- In this case, `edge` corresponds to `develop`. To setup any other version, you may use the branch name or version specific tags. (eg. version-12, v11.1.15, v11).
|
||||
- `MYSQL_ROOT_PASSWORD=admin`
|
||||
- Bootstraps a MariaDB container with this value set as the root password. If a managed MariaDB instance is used, there is no need to set the password here.
|
||||
- `MARIADB_HOST=mariadb`
|
||||
- Sets the hostname to `mariadb`. This is required if the database is managed by the containerized MariaDB instance.
|
||||
- In case of a separately managed database setups, set the value to the database's hostname/IP/domain.
|
||||
- `SITE_NAME=mysite.localhost`
|
||||
- Creates this site after starting all services and installs ERPNext.
|
||||
- ``SITES=`${SITE_NAME}` ``
|
||||
- List of sites that are part of the deployment "bench" Each site is separated by a comma(,) and quoted in backtick (`). By default site created by ``SITE_NAME`` variable is added here.
|
||||
- If LetsEncrypt is being setup, make sure that the DNS for all the site's domains correctly point to the current instance.
|
||||
- `LETSENCRYPT_EMAIL=your.email@your.domain.com`
|
||||
- Email for LetsEncrypt expiry notification. This is only required if you are setting up LetsEncrypt.
|
||||
|
||||
Notes:
|
||||
|
||||
- `AUTO_MIGRATE` variable is set to `1` by default. It checks if there is semver bump or git hash change in case of develop branch and automatically migrates the sites on container start up.
|
||||
- It is good practice to use image tag for specific version instead of latest. e.g `frappe-socketio:v12.5.1`, `erpnext-nginx:v12.7.1`.
|
||||
|
||||
## Start containers
|
||||
|
||||
Execute the following command:
|
||||
|
||||
```sh
|
||||
docker-compose --project-name <project-name> up -d
|
||||
```
|
||||
|
||||
Make sure to replace `<project-name>` with the desired name you wish to set for the project.
|
||||
|
||||
Notes:
|
||||
|
||||
- The local deployment is for testing and REST API development purpose only
|
||||
- A complete development environment is available [here](development)
|
||||
- The site names are limited to patterns matching \*.localhost by default
|
||||
- Additional site name patterns can be added by editing /etc/hosts of your host machine
|
||||
|
||||
## Docker containers
|
||||
|
||||
The docker-compose file contains following services:
|
||||
|
||||
* traefik: manages letsencrypt
|
||||
* volume: cert-vol
|
||||
* redis-cache: cache store
|
||||
* volume: redis-cache-vol
|
||||
* redis-queue: used by workers
|
||||
* volume: redis-queue-vol
|
||||
* redis-socketio: used by socketio service
|
||||
* volume: redis-socketio-vol
|
||||
* mariadb: main database
|
||||
* volume: mariadb-vol
|
||||
* erpnext-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port.
|
||||
* volume: assets-vol and sites-vol
|
||||
* erpnext-python: main application code
|
||||
* volume: sites-vol and sites-vol
|
||||
* frappe-socketio: enables realtime communication to the user interface through websockets
|
||||
* volume: sites-vol
|
||||
* erpnext-worker-default: background runner
|
||||
* volume: sites-vol
|
||||
* erpnext-worker-short: background runner for short-running jobs
|
||||
* volume: sites-vol
|
||||
* erpnext-worker-long: background runner for long-running jobs
|
||||
* volume: sites-vol
|
||||
* erpnext-schedule
|
||||
* volume: sites-vol
|
||||
* site-creator: run once container to create new site.
|
||||
* volume: sites-vol
|
||||
|
||||
## Updating and Migrating Sites
|
||||
|
||||
Switch to the root of the `frappe_docker` directory before running the following commands:
|
||||
|
||||
```sh
|
||||
# Update environment variables ERPNEXT_VERSION and FRAPPE_VERSION
|
||||
nano .env
|
||||
|
||||
# Pull new images
|
||||
docker-compose pull
|
||||
|
||||
# Restart containers
|
||||
docker-compose --project-name <project-name> up -d
|
||||
```
|
||||
161
docs/site-operations.md
Normal file
161
docs/site-operations.md
Normal file
@@ -0,0 +1,161 @@
|
||||
# Site operations
|
||||
|
||||
Create and use env file to pass environment variables to containers,
|
||||
|
||||
```sh
|
||||
source .env
|
||||
```
|
||||
|
||||
Or specify environment variables instead of passing secrets as command arguments. Refer notes section for environment variables required
|
||||
|
||||
## Setup New Site
|
||||
|
||||
Note:
|
||||
|
||||
- Wait for the MariaDB service to start before trying to create a new site.
|
||||
- If new site creation fails, retry after the MariaDB container is up and running.
|
||||
- If you're using a managed database instance, make sure that the database is running before setting up a new site.
|
||||
|
||||
```sh
|
||||
# Create ERPNext site
|
||||
docker run \
|
||||
-e "SITE_NAME=$SITE_NAME" \
|
||||
-e "DB_ROOT_USER=$DB_ROOT_USER" \
|
||||
-e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \
|
||||
-e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \
|
||||
-e "INSTALL_APPS=erpnext" \
|
||||
-v <project-name>_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
--network <project-name>_default \
|
||||
frappe/erpnext-worker:$VERSION new
|
||||
```
|
||||
|
||||
Environment Variables needed:
|
||||
|
||||
- `SITE_NAME`: name of the new site to create.
|
||||
- `DB_ROOT_USER`: MariaDB Root user.
|
||||
- `MYSQL_ROOT_PASSWORD`: In case of the MariaDB docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of a managed database use the appropriate password.
|
||||
- `MYSQL_ROOT_PASSWORD_FILE` - When the MariaDB root password is stored using docker secrets.
|
||||
- `ADMIN_PASSWORD`: set the administrator password for the new site.
|
||||
- `ADMIN_PASSWORD_FILE`: set the administrator password for the new site using docker secrets.
|
||||
- `INSTALL_APPS=erpnext`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site.
|
||||
- `FORCE=1`: optional variable which force installation of the same site.
|
||||
|
||||
## Add sites to proxy
|
||||
|
||||
Change `SITES` variable to the list of sites created encapsulated in backtick and separated by comma with no space. e.g. ``SITES=`site1.example.com`,`site2.example.com` ``.
|
||||
|
||||
Reload variables with following command.
|
||||
|
||||
```sh
|
||||
docker-compose up --project-name <project-name> -d
|
||||
```
|
||||
|
||||
## Backup Sites
|
||||
|
||||
Environment Variables
|
||||
|
||||
- `SITES` is list of sites separated by `:` colon to migrate. e.g. `SITES=site1.domain.com` or `SITES=site1.domain.com:site2.domain.com` By default all sites in bench will be backed up.
|
||||
- `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-vol:/{site-name}/private/backups/*`
|
||||
|
||||
```sh
|
||||
docker run \
|
||||
-e "SITES=site1.domain.com:site2.domain.com" \
|
||||
-e "WITH_FILES=1" \
|
||||
-v <project-name>_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
--network <project-name>_default \
|
||||
frappe/erpnext-worker:$VERSION backup
|
||||
```
|
||||
|
||||
The backup will be available in the `sites-vol` volume.
|
||||
|
||||
## Push backup to s3 compatible storage
|
||||
|
||||
Environment Variables
|
||||
|
||||
- `BUCKET_NAME`, Required to set bucket created on S3 compatible storage.
|
||||
- `REGION`, Required to set region for S3 compatible storage.
|
||||
- `ACCESS_KEY_ID`, Required to set access key.
|
||||
- `SECRET_ACCESS_KEY`, Required to set secret access key.
|
||||
- `ENDPOINT_URL`, Required to set URL of S3 compatible storage.
|
||||
- `BUCKET_DIR`, Required to set directory in bucket where sites from this deployment will be backed up.
|
||||
- `BACKUP_LIMIT`, Optionally set this to limit number of backups in bucket directory. Defaults to 3.
|
||||
|
||||
```sh
|
||||
docker run \
|
||||
-e "BUCKET_NAME=backups" \
|
||||
-e "REGION=region" \
|
||||
-e "ACCESS_KEY_ID=access_id_from_provider" \
|
||||
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \
|
||||
-e "ENDPOINT_URL=https://region.storage-provider.com" \
|
||||
-e "BUCKET_DIR=frappe-bench" \
|
||||
-v <project-name>_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
--network <project-name>_default \
|
||||
frappe/frappe-worker:$VERSION push-backup
|
||||
```
|
||||
|
||||
Note:
|
||||
|
||||
- Above example will backup files in bucket called `backup` at location `frappe-bench-v12/site.name.com/DATE_TIME/DATE_TIME-site_name_com-{filetype}.{extension}`,
|
||||
- example DATE_TIME: 20200325_042020.
|
||||
- example filetype: database, files or private-files
|
||||
- example extension: sql.gz or tar
|
||||
|
||||
## Restore backups
|
||||
|
||||
Environment Variables
|
||||
|
||||
- `MYSQL_ROOT_PASSWORD` or `MYSQL_ROOT_PASSWORD_FILE`(when using docker secrets), Required to restore mariadb backups.
|
||||
- `BUCKET_NAME`, Required to set bucket created on S3 compatible storage.
|
||||
- `ACCESS_KEY_ID`, Required to set access key.
|
||||
- `SECRET_ACCESS_KEY`, Required to set secret access key.
|
||||
- `ENDPOINT_URL`, Required to set URL of S3 compatible storage.
|
||||
- `REGION`, Required to set region for s3 compatible storage.
|
||||
- `BUCKET_DIR`, Required to set directory in bucket where sites from this deployment will be backed up.
|
||||
|
||||
```sh
|
||||
docker run \
|
||||
-e "MYSQL_ROOT_PASSWORD=admin" \
|
||||
-e "BUCKET_NAME=backups" \
|
||||
-e "REGION=region" \
|
||||
-e "ACCESS_KEY_ID=access_id_from_provider" \
|
||||
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \
|
||||
-e "ENDPOINT_URL=https://region.storage-provider.com" \
|
||||
-e "BUCKET_DIR=frappe-bench" \
|
||||
-v <project-name>_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
-v ./backups:/home/frappe/backups \
|
||||
--network <project-name>_default \
|
||||
frappe/frappe-worker:$VERSION restore-backup
|
||||
```
|
||||
|
||||
Note:
|
||||
|
||||
- Volume must be mounted at location `/home/frappe/backups` for restoring sites
|
||||
- If no backup files are found in volume, it will use s3 credentials to pull backups
|
||||
- Backup structure for mounted volume or downloaded from s3:
|
||||
- /home/frappe/backups
|
||||
- site1.domain.com
|
||||
- 20200420_162000
|
||||
- 20200420_162000-site1_domain_com-*
|
||||
- site2.domain.com
|
||||
- 20200420_162000
|
||||
- 20200420_162000-site2_domain_com-*
|
||||
|
||||
## Edit configs
|
||||
|
||||
Editing config manually might be required in some cases,
|
||||
one such case is to use Amazon RDS (or any other DBaaS).
|
||||
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.
|
||||
|
||||
`common_site_config.json` or `site_config.json` from `sites-vol` volume has to be edited using following command:
|
||||
|
||||
```sh
|
||||
docker run \
|
||||
-it \
|
||||
-v <project-name>_sites-vol:/sites \
|
||||
alpine vi /sites/common_site_config.json
|
||||
```
|
||||
|
||||
Instead of `alpine` use any image of your choice.
|
||||
15
docs/tips-for-moving-deployments.md
Normal file
15
docs/tips-for-moving-deployments.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Tips for moving deployments
|
||||
|
||||
- Take regular automatic backups and push the files to S3 compatible cloud. Setup backup and push with cronjobs
|
||||
- Use regular cron for single machine installs
|
||||
- Use [swarm-cronjob](https://github.com/crazy-max/swarm-cronjob) for docker swarm
|
||||
- Use Kubernetes CronJob
|
||||
- It makes it easy to transfer data from cloud to any new deployment.
|
||||
- They are just [site operations](site-operations) that can be manually pipelined as per need.
|
||||
- Remember to restore encryption keys and other custom configuration from `site_config.json`.
|
||||
- Steps to move deployment:
|
||||
- [Take backup](site-operations#backup-sites)
|
||||
- [Push backup to cloud](site-operations#push-backup-to-s3-compatible-storage)
|
||||
- Create new deployment type anywhere
|
||||
- [Restore backup from cloud](site-operations#restore-backups)
|
||||
- [Restore `site_config.json` from cloud](site-operations#edit-configs)
|
||||
Reference in New Issue
Block a user