[Guide] ERPNext-14 Production Setup (Docker)

ERPNext-14 Production Setup

In this Setup we assume that you have the Custom App and you are using mariadb and OS is Ubuntu 18+.

ERP Discuss

Step 1:

Load the Custom App and other apps are hrms & payments module.

assume my custom app is custom_erpnext

Clone the frappe_docker. Open your Terminal.

Run Command


git clone https://github.com/frappe/frappe_docker

assume you’re using this domain ziptor.com. Note: It’s only for testing purposes don’t use this use your correct domain

Change the frappe_docker folder name to ziptor. Note: this step is only for understanding it’s not necessary

Run Command


sudo mv frappe_docker ziptor

cd ziptor

Load the custom App

Run Command


export APPS_JSON='[

{

"url": "https://github.com/frappe/erpnext",

"branch": "v14.24.1"

},

{

"url": "https://github.com/frappe/hrms",

"branch": "version-14"

},

{

"url": "https://github.com/frappe/payments",

"branch": "version-14"

},

{

"url": "https://access_token@github.com/my-github/custom_app",

"branch": "main"

}

]'

Note: change your custom app repo link and access_token and respective branch

Run Command


export APPS_JSON_BASE64=$(echo ${APPS_JSON} | base64 -w 0)

After taking your custom image change the compose.yaml file


x-customizable-image: &customizable_image

image: customapp:1.0.0

pull_policy: never

Run Command


docker build \

--build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \

--build-arg=FRAPPE_BRANCH=v14.24.1 \

--build-arg=PYTHON_VERSION=3.10.5 \

--build-arg=NODE_VERSION=16.16.0 \

--build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \

--tag=customapp:1.0.0 \

--file=images/custom/Containerfile .

Note: custom_app_14:1.0.0 is your custom image

:warning:Note​:warning:: after taking the build if you want to update the code add --no-cache in the command. like this.


docker build --no-cache \

--build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \

--build-arg=FRAPPE_BRANCH=v14.24.1 \

--build-arg=PYTHON_VERSION=3.10.5 \

--build-arg=NODE_VERSION=16.16.0 \

--build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \

--tag=customapp:1.0.0 \

--file=images/custom/Containerfile .

Step 2:

Create configuration and resources directory

Run Command


mkdir ~/gitops

Step 3:

Basic Traefik setup using docker compose. Create a file called traefik.env in ~/gitops

Run Command


echo 'TRAEFIK_DOMAIN=ziptor.com' > ~/gitops/traefik.env

echo 'EMAIL=admin@ziptor.com' >> ~/gitops/traefik.env

echo 'HASHED_PASSWORD='$(openssl passwd -apr1 changeit | sed 's/\$/\\\$/g') >> ~/gitops/traefik.env

Deploy the traefik container with letsencrypt SSL

Run Command


docker compose --project-name traefik \

--env-file ~/gitops/traefik.env \

-f overrides/compose.traefik.yaml \

-f overrides/compose.traefik-ssl.yaml up -d

Step 4

Install MariaDB

Basic MariaDB setup using docker compose. Create a file called mariadb.env in ~/gitops

Run Command


echo "DB_PASSWORD=changeit" > ~/gitops/mariadb.env

Note:

Change the password from changeit to more secure. env file generated at location ~/gitops/mariadb.env will look like following:

Deploy the mariadb container


docker compose --project-name mariadb --env-file ~/gitops/mariadb.env -f overrides/compose.mariadb-shared.yaml up -d

Step 5

Install ERPNext

Create First Bench

Create first bench called erpnext-one with ziptor.com.

Create a file called erpnext-one.env in ~/gitops

Run Command


cp example.env ~/gitops/erpnext-one.env

sed -i 's/DB_PASSWORD=123/DB_PASSWORD=changeit/g' ~/gitops/erpnext-one.env

sed -i 's/DB_HOST=/DB_HOST=mariadb-database/g' ~/gitops/erpnext-one.env

sed -i 's/DB_PORT=/DB_PORT=3306/g' ~/gitops/erpnext-one.env

sed -i 's/SITES=`erp.example.com`/SITES=\`ziptor.com\`/g' ~/gitops/erpnext-one.env

echo 'ROUTER=erpnext-one' >> ~/gitops/erpnext-one.env

echo "BENCH_NETWORK=erpnext-one" >> ~/gitops/erpnext-one.env

Create erpnext-one.yaml

Run Command


docker compose --project-name erpnext-one \

--env-file ~/gitops/erpnext-one.env \

-f compose.yaml \

-f overrides/compose.redis.yaml \

-f overrides/compose.multi-bench.yaml \

-f overrides/compose.multi-bench-ssl.yaml config > ~/gitops/erpnext-one.yaml

Deploy erpnext-one containers:

Run Command


docker compose --project-name erpnext-one -f ~/gitops/erpnext-one.yaml up -d

Create sites ziptor.com:


docker compose --project-name erpnext-one exec backend \

bench new-site ziptor.com --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit

Note: change the correct DB and Admin password changeit to some secure one

----------------------------------------🔥SET UP DONE🔥--------------------------------------------

But here you have to notice something. the sechedular is disabled

Schedular

List of containers using custom image i mean customapp


erpnext-one-frontend-1

erpnext-one-backend-1

erpnext-one-queue-short-1

erpnext-one-scheduler-1

erpnext-one-websocket-1

erpnext-one-queue-long-1

erpnext-one-queue-default-1

Use this command to check in all these containers your custom app installed.


docker exec -it <CONTAINER_NAME> bash

example


docker exec -it erpnext-one-frontend-1 bash

Enable Schedular


bench --site ziptor.com enable-scheduler

8 Likes

Thanks for your nice tutorial.

@Antony_Praveenkumar
how we could update the ERPNext to the specific version of ERPNext, in side the container?

1 Like

Could you explain this , what mean by update the codes?

You have have custom_app if you want to deploy the erpnext with new features you have to update your custom_app code right for that you have to again built a Custom Image in that case you already have a image customapp:1.0.0 if you run the normal command, the code won’t be updated. for that you have to use --no--cache tag in docker built command.

what is the meaning of this setting?

the pull_policy setting determines whether a container image should be pulled from the registry or not

you are wonderfull

1 Like

@Antony_Praveenkumar This is really helpful
Thanks

While creating the site you didn’t install the custom apps loaded earlier (hrms, payments). Are they installed along with the image built earlier?

yes you have to navigate inside the container and install all your apps like

bench --site mysite.com install-app hrms
bench --site mysite.com install-app payments
bench --site mysite.com install-app custom_app
1 Like

Do you mean to use install-app?

bench --site mysite.com install-app hrms

yes sorry typo. please check now

1 Like

I keep having problems with this output. It seems like traefik is not parsing the password the way it is intended. If the reader’s facing the same problem as I am, he can single quote the output in traefik.env file. Or do that in the echo command:

echo 'HASHED_PASSWORD='$(openssl passwd -apr1 changeit | sed 's/\(^.*$\)/\x27\1\x27/g') >> ~/gitops/traefik.env

After doing the above, no more complains from traefik startup.

2 Likes