We are planning to deploy ERPNext by leveraging Docker.
We have built a Centos 7 docker container that is used to run the setup script in the same way it has been done by David Gu in this example: https://hub.docker.com/r/davidgu/erpnext/
Docker container does not enable systemd to run in the container, unless you use certain privileges or loop holes ( see Blog Landing Page | Red Hat Developer for more details)
In our case, we have used supervisord in the Docker container to start and stop the different services during the ERPNext installation - I can share the Dockerfile and installation script if you are interested.
At some point during the ERPNext app installation, the frappe framework tries to restart its different services. While doing so, the framework check which service manager is used between systemd and service. If the installation script fails to identify one of those two, then the services are not restarted and the installation is aborted.
Here is my suggestion: It would be great to also check if supervisord is used as a service manager in the installation so that it can support this use case.
Let me know if you have other suggestions or ideas to workaround this issue.
I have noticed that the fix also uses an addition env variable called BENCH_SERVICE_MANAGER_COMMAND.
So I have set it as well and everything seems to work well until the following error pops up:
Context = (Logged as root in the frappe-bench directory)
Actually, in this case, if youâve setup nginx/mysql/redis, etc via supervisor itself, we can skip calling restat_service('nginx') all together because we do a full supervisor reload just before that, so a feature like SKIP_RESTART_SERVICE would do the job.
If you can share your Dockerfile, Iâll make it working and submit to docker hub as well
Yes, that makes sense - no need to restart the service NGinx, you are right, Pratik.
Here is the Dockerfile - feel free to make some adjustments or suggestions before submitting to docker hub:
FROM centos:7
ENV FRAPPE_USER erpnext
ENV HOSTNAME <set your hostname>
ENV BENCH_SERVICE_MANAGER supervisorctl
RUN yum -y update && yum -y clean all && yum update python -y
RUN yum -y install wget ca-certificates sudo rpm-cron python-setuptools MySQL-python httpd mysql mysql-server mysql-devel git memcached ntp vim
RUN easy_install pip && pip install pytz python-dateutil jinja2 markdown2 termcolor python-memcached requests chardet dropbox google-api-python-client pygeoip
RUN easy_install supervisor
# Create a new user for frappe
RUN useradd $FRAPPE_USER && chown -R $FRAPPE_USER.$FRAPPE_USER /home/$FRAPPE_USER && chmod a+x /home/$FRAPPE_USER
#Fix issue with /run write access
RUN chmod a+w /run
WORKDIR /home/$FRAPPE_USER
COPY frappe_passwords.sh /root/frappe_passwords.sh
# Need to preload the supervisord configuration as we use supervisord as a service manager
COPY all.conf /etc/supervisord.d/all.ini
# Copy the updated version of the frappe install script
COPY setup_frappe.sh setup_frappe.sh
# Running an updated version of the Frappe installation script
RUN bash setup_frappe.sh --frappe-user $FRAPPE_USER --setup-production
# Make sure the volume is in sync with the frappe username
VOLUME ["/var/lib/mysql", "/home/erpnext/frappe-bench/sites/<type your sitename here>/"]
EXPOSE 80
CMD ["/usr/bin/supervisord","-n"]
I still have an error message when completing the installation manually in my Centos7 Docker instance.
When running the last installation step of the setup script, I receive an error message regarding the command to restart NGinx - as you have mentioned earlier, we could skip this step since we do a full supervisor reload just before.
If you provide a feature like SKIP_RESTART_SERVICE, this could be a good workaround.
Here is the full trace:
# bench setup production erpnext
Restarted supervisord
error: <class 'xmlrpclib.Fault'>, <Fault 6: 'SHUTDOWN_STATE'>: file: /usr/lib64/python2.7/xmlrpclib.py line: 793
Traceback (most recent call last):
File "/usr/bin/bench", line 9, in <module>
load_entry_point('bench==0.92', 'console_scripts', 'bench')()
File "/home/erpnext/bench-repo/bench/cli.py", line 60, in cli
bench()
File "/usr/lib64/python2.7/site-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/usr/lib64/python2.7/site-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/usr/lib64/python2.7/site-packages/click/core.py", line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib64/python2.7/site-packages/click/core.py", line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib64/python2.7/site-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib64/python2.7/site-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/home/erpnext/bench-repo/bench/cli.py", line 456, in setup_production
_setup_production(user=user)
File "/home/erpnext/bench-repo/bench/production_setup.py", line 67, in setup_production
restart_service('nginx')
File "/home/erpnext/bench-repo/bench/production_setup.py", line 18, in restart_service
exec_cmd(service_manager_command)
File "/home/erpnext/bench-repo/bench/utils.py", line 104, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: supervisorctl restart nginx
Thanks, Pratik.
I have tried it in my environment and after a few tries, I realized the variable is actually called âNO_SERVICE_RESTARTâ.
After setting it to true, it worked like a charm with no error code returned.
I am going to update my Dockerfile to include this change and generate a new image.
Sure, I need to make a few adjustments to make it generic and remove some custom pieces, like the default site name.
I should have this ready during next week.
@dgrelin just stumbled over this thread from some time ago. Have you done a docker file which could be used in the meantime? Would you mind to post the docker repo here?
Hello @pdvyas, I see thereâs a huge demand for an official docker setup and Iâm interested as well. If I understand correctly you managed to make it working. Could you publish it on docker hub please?