Try ERPNext Buy Support Partners Foundation

Docker based production installation

Prerequisites:

  • Docker
  • docker-compose
  • List of sites and server ip added to DNS

1. Install docker-compose-letsencrypt-nginx-proxy-companion

cd $HOME
git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion
cd docker-compose-letsencrypt-nginx-proxy-companion
cp .env.sample .env
./start.sh

2. Clone repository

cd $HOME
git clone https://gitlab.com/castlecraft/erpnext_kubernetes.git
cd erpnext_kubernetes
touch .env

3. Setup .env file

  • MYSQL_ROOT_PASSWORD=admin, set mariadb root password (bootstraps a mariadb container with this root password)
  • SITES=site1.domain.com,site2.domain.com these are list of sites that are part of the bench. Comma (,) separated
  • LETSENCRYPT_EMAIL=your.email@your.domain.com email to for letsencrypt expiry notification

Note: To add more sites recreate erpnext-assets container with sites appended to SITES ENV variable

4. Uncomment following lines from docker/docker-compose-${VERSION}.yml

...

networks:
  default:
    external:
      name: webproxy

5. Comment the exposed port 80:80 from docker/docker-compose-${VERSION}.yml from erpnext-assets service

...
#   ports:
#     - "80:80"

6. Start services (replace appropriate version)

DNS needs to be configured for following to work

docker-compose \
    --project-name erpnext_kubernetes \
    -f docker/docker-compose-$VERSION.yml \
    --project-directory . up -d

7. create new site(s)

# Create ERPNext site
docker exec \
    -e "SITE_NAME=site1.domain.com" \
    -e "INSTALL_ERPNEXT=1" \
    -it erpnext_kubernetes_erpnext-python_1 docker-entrypoint.sh new

# Create Frappe only site
docker exec \
    -e "SITE_NAME=site2.domain.com" \
    -it erpnext_kubernetes_erpnext-python_1 docker-entrypoint.sh new

Wait for mariadb to start. If new site creation fails re-try again after mariadb container is up

8. Update sites

cd $HOME/erpnext_kubernetes

# Pull new images
docker-compose -f docker/docker-compose-$VERSION.yml pull

# Restart containers
docker-compose \
    --project-name erpnext_kubernetes \
    -f docker/docker-compose-$VERSION.yml \
    --project-directory . restart

docker exec \
    -e "MAINTENANCE_MODE=1" \
    -it erpnext_kubernetes_erpnext-python_1 docker-entrypoint.sh migrate

If migrate fails because of redis cache related error remove the redis container(s) and volume(s) and migrate again

docker-compose \
    --project-name erpnext_kubernetes \
    -f docker/docker-compose-$VERSION.yml \
    --project-directory . stop

docker-compose \
    -f docker/docker-compose-$VERSION.yml \
    --project-directory . rm redis-cache redis-queue redis-socketio

docker volume rm \
    erpnext_kubernetes_redis-cache-vol \
    erpnext_kubernetes_redis-queue-vol \
    erpnext_kubernetes_redis-socketio-vol

docker-compose \
    --project-name erpnext_kubernetes \
    -f docker/docker-compose-$VERSION.yml \
    --project-directory . up -d

Read more:

10 Likes

./start should be ./start.sh, right?

1 Like

Fixed

1 Like

@revant_one could you please add instructions on how to restore a backup?

Would it also be possible to use an external database like AWS RDS?

nothing special in container to restore backups.
Manually extract the user uploaded files in appropriate volumes or paths
Manually restore or create database with credentials from site_config.json
For restoring multiple dbs across servers, rsync seems faster.

rsync -avz /var/lib/mysql/* user@example.com:/var/lib/mysql/ 

# at destination as root
chown mysql:mysql -R /var/lib/mysql/

https://www.tecmint.com/transfer-mysql-databases-from-old-to-new-server/

I have success with using separate server under private network (Not Amazon RDS).

Instead of starting the mariadb service, pass your own db_host as environment variable MARIADB_HOST to erpnext-python container. It will create the config with the passed db_host. Other needed config can be changed manually as it will be available in sites directory on host

Related wiki : https://github.com/frappe/frappe/wiki/Using-Frappe-with-Amazon-RDS-(or-any-other-DBaaS)

2 Likes

Hello revant_one,

did you have a solution to use your Docker Container with an external Database?

https://hub.docker.com/_/mariadb

Did we get a ERPNextofficial/ERPNext Container on https://hub.docker.com ?

Wher can i find yout Dockerfile?

one is one, first

Thanks

jannis

Yes

No

Dockerfile(s) for edge images built from develop branch

git repo: https://gitlab.com/castlecraft/erpnext_kubernetes

Hello, i’m confused, which ERPNext i the Master Branch, v11 oder v12 at this time?

jannis

There is only master branch

3 directories,
each directory will have Dockerfile. i.e. 3 Dockerfiles
plain Dockerfile is for develop branch.
there is also v11.Dockerfile and v12.Dockerfile

Read docker-entrypoint.sh(s) and Dockerfile(s) to know more

  • erpnext-python image is ERPNext Python environment. Start 5x containers out of it viz. gunicorn, worker-default, worker-short,worker-long,scheduler`. sites/assets directory in gunicorn container is populated by erpnext-assets container.
  • erpnext-assets image serves pre-built assets and populates assets for gunicorn serving jinja
  • frappe-socketio image is the express, socketio server that is needed for websocket