2022-03-14 05:53:03 +00:00
|
|
|
# Containerized Production Setup
|
|
|
|
|
|
|
|
Make sure you've cloned this repository and switch to the directory before executing following commands.
|
|
|
|
|
|
|
|
Commands will generate YAML as per the environment for setup.
|
|
|
|
|
2022-05-02 00:17:53 +00:00
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
- [docker](https://docker.com/get-started)
|
|
|
|
- [docker compose v2](https://docs.docker.com/compose/cli-command)
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
## Setup Environment Variables
|
|
|
|
|
|
|
|
Copy the example docker environment file to `.env`:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cp example.env .env
|
|
|
|
```
|
|
|
|
|
2023-08-08 04:08:36 +00:00
|
|
|
Note: To know more about environment variable [read here](./environment-variables.md). Set the necessary variables in the `.env` file.
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
## Generate docker-compose.yml for variety of setups
|
|
|
|
|
2022-05-02 00:17:53 +00:00
|
|
|
Notes:
|
|
|
|
|
|
|
|
- Make sure to replace `<project-name>` with the desired name you wish to set for the project.
|
|
|
|
- This setup is not to be used for development. A complete development environment is available [here](../development)
|
|
|
|
|
|
|
|
### Store the yaml files
|
|
|
|
|
|
|
|
YAML files generated by `docker compose config` command can be stored in a directory. We will create a directory called `gitops` in the user's home.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
mkdir ~/gitops
|
|
|
|
```
|
|
|
|
|
|
|
|
You can make the directory into a private git repo which stores the yaml and secrets. It can help in tracking changes.
|
|
|
|
|
|
|
|
Instead of `docker compose config`, you can directly use `docker compose up` to start the containers and skip storing the yamls in `gitops` directory.
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
### Setup Frappe without proxy and external MariaDB and Redis
|
|
|
|
|
2022-05-02 00:17:53 +00:00
|
|
|
In this case make sure you've set `DB_HOST`, `DB_PORT`, `REDIS_CACHE`, `REDIS_QUEUE` and `REDIS_SOCKETIO`
|
|
|
|
environment variables or the `configurator` will fail.
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
```sh
|
|
|
|
# Generate YAML
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose -f compose.yaml -f overrides/compose.noproxy.yaml config > ~/gitops/docker-compose.yml
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
# Start containers
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml up -d
|
2022-03-14 05:53:03 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Setup ERPNext with proxy and external MariaDB and Redis
|
|
|
|
|
2022-05-02 00:17:53 +00:00
|
|
|
In this case make sure you've set `DB_HOST`, `DB_PORT`, `REDIS_CACHE`, `REDIS_QUEUE` and `REDIS_SOCKETIO`
|
|
|
|
environment variables or the `configurator` will fail.
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
```sh
|
|
|
|
# Generate YAML
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose -f compose.yaml \
|
2022-03-14 05:53:03 +00:00
|
|
|
-f overrides/compose.proxy.yaml \
|
|
|
|
config > ~/gitops/docker-compose.yml
|
|
|
|
|
|
|
|
# Start containers
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml up -d
|
2022-03-14 05:53:03 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Setup Frappe using containerized MariaDB and Redis with Letsencrypt certificates.
|
|
|
|
|
2023-02-02 08:15:06 +00:00
|
|
|
In this case make sure you've set `LETSENCRYPT_EMAIL` and `SITES` environment variables are set or certificates won't work.
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
```sh
|
|
|
|
# Generate YAML
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose -f compose.yaml \
|
2022-03-14 05:53:03 +00:00
|
|
|
-f overrides/compose.mariadb.yaml \
|
|
|
|
-f overrides/compose.redis.yaml \
|
|
|
|
-f overrides/compose.https.yaml \
|
|
|
|
config > ~/gitops/docker-compose.yml
|
|
|
|
|
|
|
|
# Start containers
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml up -d
|
2022-03-14 05:53:03 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Setup ERPNext using containerized MariaDB and Redis with Letsencrypt certificates.
|
|
|
|
|
2023-02-02 08:15:06 +00:00
|
|
|
In this case make sure you've set `LETSENCRYPT_EMAIL` and `SITES` environment variables are set or certificates won't work.
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
```sh
|
|
|
|
# Generate YAML
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose -f compose.yaml \
|
2022-03-14 05:53:03 +00:00
|
|
|
-f overrides/compose.mariadb.yaml \
|
|
|
|
-f overrides/compose.redis.yaml \
|
|
|
|
-f overrides/compose.https.yaml \
|
|
|
|
config > ~/gitops/docker-compose.yml
|
|
|
|
|
|
|
|
# Start containers
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml up -d
|
2022-03-14 05:53:03 +00:00
|
|
|
```
|
|
|
|
|
2022-05-02 00:17:53 +00:00
|
|
|
## Create first site
|
2022-03-14 05:53:03 +00:00
|
|
|
|
2022-05-02 00:17:53 +00:00
|
|
|
After starting containers, the first site needs to be created. Refer [site operations](./site-operations.md#setup-new-site).
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
## Updating Images
|
|
|
|
|
|
|
|
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
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose -f compose.yaml \
|
2022-03-14 05:53:03 +00:00
|
|
|
# ... your other overrides
|
|
|
|
config > ~/gitops/docker-compose.yml
|
|
|
|
|
2023-01-28 07:10:46 +00:00
|
|
|
# Pull images
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml pull
|
|
|
|
|
|
|
|
# Stop containers
|
|
|
|
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml down
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
# Restart containers
|
2022-05-02 00:17:53 +00:00
|
|
|
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml up -d
|
2022-03-14 05:53:03 +00:00
|
|
|
```
|
|
|
|
|
2023-01-28 07:10:46 +00:00
|
|
|
Note:
|
|
|
|
|
|
|
|
- pull and stop container commands can be skipped if immutable image tags are used
|
|
|
|
- `docker compose up -d` will pull new immutable tags if not found.
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
To migrate sites refer [site operations](./site-operations.md#migrate-site)
|