Kubernetes: Decoupled Frappe/ERPNext docker images

I changed the URL to end with .git and it worked!
so the git clone command that worked for me was:

git clone https://gitlab.com/revant.one/erpnext_kubernetes.git && cd erpnext_kubernetes

Thanks @revant_one! I am going to try this out this weekend. I have had pretty poor performance (write latency) with s3fs style solutions previously, did csi-s3 work OK?

During setup (writing config files) I didn’t feel any difference.

Probably I’ll need to try for few days.

I’m not using s3fs. I’m using goofys GitHub - kahing/goofys: a high-performance, POSIX-ish Amazon S3 file system written in Go

1 Like

I have a schedule that builds version tagged images for v11, v12 and edge. Check updated post
It is ready for production deployment, checkout the gitlab repo.

I’ll write a separate post on

  • how to setup a dockerized erpnext in production with letsencrypt.
  • how to setup erpnext on kubernetes using helm chart
3 Likes

I guess those instructions are what you’ll have to follow:

I’ll check that out in a bit. thanks thus far @revant_one

1 Like

Just for reference I posted same on forum

for helm chart check the directory kubernetes/erpnext from the repo.

Based on that, I’ll write about kubernetes based installation.

1 Like

I try to run the v12 following these instructions edition but can’t really achieve a running system.

when I am executing the

docker exec -it \
    -e SITE_NAME=test.localhost \
    -e DB_ROOT_USER=root \
    -e DB_ROOT_PASSWORD=admin \
    -e ADMIN_PASSWORD=admin \
    -e INSTALL_ERPNEXT=1 \
    erpnext_kubernetes_erpnext-python_1 docker-entrypoint.sh new

I am getting Site test.localhost already exists
I can, however go through with this when I choose a different site name. However I can not access my http://test2.localhost site afterwards

also in the terminal that is running the docker-compose ... up command I have noted

mariadb_1 | 2019-12-08 23:57:02 50 [Warning] Access denied for user '_fcadc07dbdbc21db'@'172.21.0.10' (using password: YES)

I am wondering what I may be doing wrong

I fixed it and also added environment variable for FORCE=1, It will force re-installation if required

@revant_one thanks for this.

Have been trying to experiment with this but could not get it to successfully run. I’m up to a point where I can see the “Sorry! We will be back soon” page.

The erpnext_kubernetes_erpnext-python_1 container seems to have started fine based on the logs:
image

But I can not get past this. Any idea what I may be doing wrong?

Thanks.

Did you add the first site? castlecraft / erpnext_kubernetes · GitLab

Nginx will proxy to site available under bench/venv

name the sites with .localhost, e.g erp.localhost for trying out locally. That way you don’t have to edit /etc/hosts and browser treats localhost as secure

Yes I added the first site. I think it is DNS related (as you have mentioned) I’m quite confused as to how it should be routing.

I tried IP address (container’s IP) and localhost, both did not work. Is there a way to get it working using port based?

I named the site as server1-docker.domain.local which is not the actual hostname of the server but something I made up, I also configured DNS to point this hostname to the actual server itself. Did I do something wrong here?

Try adding this to /etc/hosts of host machine. It should point to 127.0.0.1

For anything other than .localhost to work it needs to be added in /etc/hosts of host machine.

Port 80 of asset container is forwarded on localhost so it will be available without entering container

Easiest is to create site named server1-docker.domain.localhost instead of server1-docker.domain.local.

Hmm… Didnt seem to work.

Ok lets say I abandon this. Can I follow these instructions and then just name the site server1-docker.domain.localhost?

But from outside the host machine what URL should I type to access the site?

The host machine is server1.domain

Yes it should work for trying out things locally on your desktop machine/laptop.

For production setup where you need to access the site from domain name, refer this:

It sets up with auto renewing letsencrypt as long as your DNS points to static IP of production machine

I am trying my luck with a v12 instance but don’t quite understand how to set custom password entries with the docker exec command

docker exec -it \
    -e SITE_NAME=test.localhost \
    -e DB_ROOT_USER=root \
    -e DB_ROOT_PASSWORD=admin \
    -e ADMIN_PASSWORD=admin \
    -e INSTALL_ERPNEXT=1 \
    erpnext_kubernetes_erpnext-python_1 docker-entrypoint.sh new

if you just edit this command with custom passwords the creation fails with a reference to mariadb not accepting the password. There is some sort of reference to passwords (at least the MYSQL_ROOT_PASSWRD) in the .env file. So, how exactly would u have to set this up and match things between the .env file and the docker exec command options in order to work?

docker exec command for new site is like following command

bench new-site \
    test.localhost \
    --mariadb-root-username root \
    --mariadb-root-password admin \
    --admin-password admin \
    --install-app erpnext

This not where the root password and root user for mariadb is set. .env file sets the mariadb root password while starting the container

  • Above command will only use previously set mariadb user and password.
    • In case of docker, user is always root and password is what you set in .env
    • In case of managed db, use the appropriate user and password created on managed db here
  • The above command is correct to set ADMIN_PASSWORD=changeit for the new site to be created.

Example:

if you set MYSQL_ROOT_PASSWORD=somerandomstring in .env you can execute following command to create new site

# set MYSQL_ROOT_PASSWORD in environment
source .env

# Substitute password string with env var 
docker exec -it \
    -e SITE_NAME=test.localhost \
    -e DB_ROOT_USER=root \
    -e DB_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
    -e ADMIN_PASSWORD=admin \
    -e INSTALL_ERPNEXT=1 \
    erpnext_kubernetes_erpnext-python_1 docker-entrypoint.sh new

.env is only set once while starting the containers first time. It won’t have any effect if you change it later

To avoid passwords to be shown in shell history, also use $ADMIN_PASSWORD instead of string

1 Like

so you need to adjust the .env file to match your needs then and adjust the docker exec command according those changes when run, right? If that is so, and I can verify this I’ll add an explenation to the README once I am certain how it precisely works.

where exactly do you execute this command? inside the repository on the docker host?

Yes, right.
Thanks for verifying!

Any time there is a need to pass some secret as command line argument,
pass it as environment variable instead of plain string.
This ensures history will only show variable names instead of plain string passwords

e.g.

# "changeit" will remain in shell history
echo "changeit"

# Assuming SECRET_PASSWORD=changeit is set in .env
# $SECRET_PASSWORD will remain in shell history
echo "$SECRET_PASSWORD"

command is run on docker host, in the directory where .env file is available.

About source or . command: Dot (command) - Wikipedia

2 Likes

@revant_one Great work, I tried it.
But I have a question PLZ, about if we can using or building a docker image of ERPNExt in order to use it by the developers of the team?

docker based development environment already exists (GitHub - frappe/frappe_docker: Docker images for production and development setups of the Frappe framework and ERPNext).

I prefer traditional development install.
Perhaps that’s what helped me build these “production” docker images.

I hope to make these images official.

https://github.com/frappe/frappe_docker/issues/83

2 Likes