A working setup using docker compose

First I wanna thank those guys @ianneub @donysukardi @vrms @ihackalot and everyone contributed to this repo GitHub - donysukardi/docker-frappe which I’ve forked and based my work on .

That repo is already working but have some issues which I tried to solve, those issues are :

  • You have to build the images in your machine, and you will always get the latest version (unless you edit Dockerfiles).
  • There is no obvious way to update ERPNext version (in docker environment update should be as simple as changing image tag).
  • Database data live inside inside database container (so recreating containers breaks everything and we should be able to recreate containers if we want to use docker tags to update ERPNext version).
  • There is no obvious way to use bench commands (backup, restore … etc) without using docker exec
  • There is no obvious way to add custom modules to this setup (the only way i thought of was to make another docker image based on the erpnext image and update docker-entrypoint.sh to install my custom module)

So for the first two issues I’ve copied this file and this file with some modifications in 3 repos frappe-base, frappe and erpnext and made a script that runs locally to automate the update of those repos based on Frappe and ERPNext release tags and trigger a new build on Docker Hub (frappe-base, frappe and erpnext)

Now we have release tags on docker hub that correspond to erpnext versions so we can update our installation by simply changing an image tag on docker-compose.yml :slight_smile: , but we still have to run bench update to run patches and to get the database schema in sync with docTypes.

For the remaining issues, I’ve made some updates to docker-entrypoint.sh and docker-compose.yml and created a manage.yml in my own fork to act as an example which you can clone and use right now.

And for bench update issue, the problem is that bench patches are all about configuring the environment so it assumes that everything is installed and running in localhost, and in our case we don’t need this configuration altogether.
Another problem is that bench update depends on git even with --patches, and I preferred to remove git files from docker images to reduce size, so I’ve forked bench itself and made a very small update to enable running bench update --no-git which doesn’t depend on git nor run bench patches, and I’ve used my bench fork in frappe image.

If this sounds cool I’ll be happy to get your feedback.

5 Likes

nice, will check it out. @emadshaaban92 are you behind the bizzotech/erpnext image?

I get stuck a little after "“This will wipe your db, are you sure you want to reinstall?” stuck at "This will wipe your db, are you sure you want to reinstall?" · Issue #2 · emadshaaban92/docker-compose-erpnext · GitHub

Yes, bizzotech is my company name :slight_smile:

For the problem with the data the solution is simple, mount the data volume as external. Then ‘docker-compose down’ does not delete it. I have no experience with mariadb but with postgresql it is quite simple and works like a charm.

on docker-compsoe.yml

version: ‘2’

services:
db:
image: postgres
volumes:
- data:/var/lib/postgresql/data

volumes:
data:
external: true

Another thing, is why not start from the official alpine-based python image instead of the alpine standard? In this way we can easily change the python version to test python 3 :slight_smile:

The first point i don’t see that is a problem, for me its a important feature. We are making a deployment of an erp, and as they said the roadmap is make releases with less funcionalities but in short time. Here you can control versions with .env fileto control parameters on build time.

Is there any way to preconfigure bench to tell you where the redis servers are? I’m doing a proof of concept to have all the parameters in a .env file to control the versions, but ebench always looks in localhost to redis, even with the configuration based on the image of donysukardi [1]

/bin/sh: 1: redis-server: not found
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/bench-repo/bench/cli.py", line 40, in cli
bench_command()
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
  File "/home/frappe/bench-repo/bench/commands/make.py", line 19, in init
verbose=verbose, clone_from=clone_from)
  File "/home/frappe/bench-repo/bench/utils.py", line 68, in init
redis.generate_config(path)
  File "/home/frappe/bench-repo/bench/config/redis.py", line 39, in generate_config
"redis_version": get_redis_version(),
  File "/home/frappe/bench-repo/bench/config/redis.py", line 59, in get_redis_version
version_string = subprocess.check_output('redis-server --version', shell=True).strip()
  File "/usr/local/lib/python2.7/subprocess.py", line 219, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'redis-server --version' returned non-zero exit status 127
ERROR: Service 'erpnext' failed to build: The command '/bin/sh -c bench init frappe-bench && cd frappe-bench' returned a non-zero code: 1

[1] docker-frappe/site_config.json at master · donysukardi/docker-frappe · GitHub