[Solved] Help needed : Setup production with docker Centos host

Hi,

I’m trying to setup production server using docker.

I’ve create Docker Image pipech/erpnext which is self-contained images, it works fine in development setup

Now I want to setup production server.

First I’ve tried using sudo bench setup production but centos images doesn’t enable systemd by default, I tried setting it up using guide form Docker but I can’t get it done.


So I take a look in bench setup production command from what I understand bench setup production does 4 things (From Setup Production and bench/production_setup.py at master · frappe/bench · GitHub)

  1. make nginx conf and link it to /etc/nginx/conf.d/
  2. make supervisor conf and link it to /etc/supervisor/conf.d/
  3. load nginx
  4. load supervisor

So what I’ve done is

  1. make nginx conf and copy it to nginx image
  2. make supervisor conf and copy it to /etc/supervisor/conf.d/
  3. load nginx in nginx image using docker-compose
  4. load supervisor in erpnext image using shell script

But it didn’t work

  • localhost:8000 > This page isn’t working localhost didn’t send any data. ERR_EMPTY_RESPONSE
  • localhost:9000 > Error: ENOENT: no such file or directory, stat ‘/home/frappe/bench-dev/index.html’
  • localhost > 404 Not Found nginx/1.13.8

I’ve check supervisor is running

bench-dev-web:bench-dev-frappe-web                    RUNNING   pid 303, uptime 0:38:54
bench-dev-web:bench-dev-node-socketio                 RUNNING   pid 304, uptime 0:38:54
bench-dev-workers:bench-dev-frappe-default-worker-0   RUNNING   pid 336, uptime 0:38:52
bench-dev-workers:bench-dev-frappe-long-worker-0      RUNNING   pid 333, uptime 0:38:52
bench-dev-workers:bench-dev-frappe-schedule           RUNNING   pid 318, uptime 0:38:53
bench-dev-workers:bench-dev-frappe-short-worker-0     RUNNING   pid 355, uptime 0:38:51

Nginx is running nginx.conf is at /etc/nginx/conf.d/ in nginx image


docker-compose file is here > https://github.com/pipech/docker-centos-erpnext-production

How to use

  1. clone repository
  2. docker-compose up
  3. docker ps > find erpnext container id
  4. docker exec -it [erpnext container id] bash
  5. cd … && cd frappe-docker-conf && . init.sh

The reason I want to set up this way mostly because stability, to gain more control over bench, frappe or erpnext update (easyinstall always give you latest update), if newest commit doesn’t work I can just use old image in docker hub which i know it will work.


Thank you in advance for any help
pipech

1 Like

This is really cool! I think you’re really close.

The nginx config when generated from the frappe system, maps the site’s folder name to the host name, check the nginx config. Try doing this : add a hostname (which is the same as your site name) to /etc/hosts pointing to localhost and access it from port 80. Make sure the nginx container’s port 8000 and 80 are open.

Hi, vjFaLk

Thank you for your suggestions, I’ll try that but first one quick question.
If I get supervisor config right, Can I access the site through localhost:8000 or it has to work together with nginx?

You should be, however, I think Frappé expects a hostname or else it doesn’t work

However, this may not be the issue. Difficult to tell with so many moving parts.

Hi, vjFaLk

I’ve tried

  • add hostname to /etc/host in ERPNext container
    sudo sh -c 'echo prdsite1 localhost >> /etc/hosts'

  • open nginx container port 8000 in docker-compose.yml
    (which I have to remove port 8000 from ERPNext container)

Still doesn’t work :tired_face:

As far as i know on prodcution, it runs on port 80 …unless you set it in site_config.json; also try to disable dns multitenant

So I did an experiment

  1. Create new vm in aws and setup production server.
  2. Make sure I can access erpnext site via http://52.77.213.48
  3. Disable nginx
  4. Try access web through http://52.77.213.48:8000

The result is I can’t access web through port 8000.

This means nginx has to works together with supervisor in order to works, so I have to get both config right at the same times.

Hi,

I did successfully run production config on docker, with some error, it still not production ready but for anyone who interested please check here > https://github.com/pipech/docker-centos-erpnext-production

2 Likes

Thanks for your contribution pipech!

Maybe outline what errors you currently have - a traceback or log trail, would get responses for what to try?

zenny has worked on various environments if that might help you
https://discuss.frappe.io/search?q=%40zenny%20docker

Hi, clarkej

I’ve post error log here > [Solved] : ImportError: Module import failed for Chat Profile

:slight_smile: