[Guide] ERPNext-14 Production Setup (Docker)

yes sorry typo. please check now

1 Like

I keep having problems with this output. It seems like traefik is not parsing the password the way it is intended. If the reader’s facing the same problem as I am, he can single quote the output in traefik.env file. Or do that in the echo command:

echo 'HASHED_PASSWORD='$(openssl passwd -apr1 changeit | sed 's/\(^.*$\)/\x27\1\x27/g') >> ~/gitops/traefik.env

After doing the above, no more complains from traefik startup.

2 Likes

does this assume that you have no Traefik installed? If so how can I replicate the same for instances where I have Traefik (docker version)

If traefik is already installed check labels for frontend service and tweak them for your use

Thanks kind sir for the reply. So my current setup is somewhat a homelab, using proxmox and created a VM using Ubuntu 22 . I am managing my DNS using cloudflare. Initially i had managed using NGINX proxy manager but upon installing HRMS, i get Internal server error, efforts trying to fix it proved futile. I encountered this post and tried to follow but i encountered some errors

ERROR: failed to solve: process "/bin/sh -c useradd -ms /bin/bash frappe     && apt-get update     && apt-get install --no-install-recommends -y     curl     git     vim     nginx     gettext-base     libpango-1.0-0     libharfbuzz0b     libpangoft2-1.0-0     libpangocairo-1.0-0     restic     mariadb-client     libpq-dev     postgresql-client     wait-for-it     jq     && mkdir -p ${NVM_DIR}     && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash     && . ${NVM_DIR}/nvm.sh     && nvm install ${NODE_VERSION}     && nvm use v${NODE_VERSION}     && npm install -g yarn     && nvm alias default v${NODE_VERSION}     && rm -rf ${NVM_DIR}/.cache     && echo 'export NVM_DIR=\"/home/frappe/.nvm\"' >>/home/frappe/.bashrc     && echo '[ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\"  # This loads nvm' >>/home/frappe/.bashrc     && echo '[ -s \"$NVM_DIR/bash_completion\" ] && \\. \"$NVM_DIR/bash_completion\"  # This loads nvm bash_completion' >>/home/frappe/.bashrc     && if [ \"$(uname -m)\" = \"aarch64\" ]; then export ARCH=arm64; fi     && if [ \"$(uname -m)\" = \"x86_64\" ]; then export ARCH=amd64; fi     && downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb     && curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file     && apt-get install -y ./$downloaded_file     && rm $downloaded_file     && rm -rf /var/lib/apt/lists/*     && rm -fr /etc/nginx/sites-enabled/default     && pip3 install frappe-bench     && sed -i '/user www-data/d' /etc/nginx/nginx.conf     && ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log     && touch /run/nginx.pid     && chown -R frappe:frappe /etc/nginx/conf.d     && chown -R frappe:frappe /etc/nginx/nginx.conf     && chown -R frappe:frappe /var/log/nginx     && chown -R frappe:frappe /var/lib/nginx     && chown -R frappe:frappe /run/nginx.pid     && chmod 755 /usr/local/bin/nginx-entrypoint.sh     && chmod 644 /templates/nginx/frappe.conf.template" did not complete successfully: exit code: 3

how can i solve this?

Below is the initial command that i ran

I was trying with pwd.yml and other methods but always ended up with errors in my db container.

After trying your method, this is the first error I got:
pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on ‘mariadb-database’ ([Errno -2] Name or service not known)”)

Apparently backend and db containers were in different networks. Made them join the same and was able to create my site.

Unfortunately, I got the same packet error as other methods I was trying
2023-07-06 1:53:45 648 [Warning] Aborted connection 648 to db: ‘_3b545afc96aa58dc’ user: ‘_3b545afc96aa58dc’ host: ‘192.168.128.8’ (Got an error reading communication packets)

I already tried changing packet size to something big like --max_allowed_packet=32505856, but it looks like mariadb isn’t taking any argument from the docker compose file.

Edited manually my /etc/mysql/my.cnf changing max_allowed_packet=256M and innodb_read_only_compressed = 0, still errors and access denied to my site.

I’ve been trying for some hours to deploy with no success.

Try it as command param?

Hello @revant_one so i had to rewire my setup to use Debian 11(old stable). Come’s with minimum programs possible and upon installation it was swift and works pretty fine. And i actually never noticed the extensive doc was located in the repo. Although that is said …one last problem is upon installation, i noticed i cannot load the custom app.
This is the initial script that i ran

export APPS_JSON='[
  {
    "url": "https://github.com/frappe/erpnext",
    "branch": "v14.24.1"
  },
  {
    "url": "https://github.com/frappe/hrms",
    "branch": "version-14"
  },
  {
    "url": "https://github.com/frappe/payments",
    "branch": "version-14"
  }
]'

and finally ended it with

export APPS_JSON_BASE64=$(echo ${APPS_JSON} | base64 -w 0)

So when i tried to run this command when all is wired

bench --site mysite.com install-app hrms

or any other apps i get an error that it doesn’t exist.

No module named 'hrms'
An error occurred while installing hrms: No module named 'hrms'
Traceback (most recent call last):
  File "apps/frappe/frappe/utils/caching.py", line 55, in wrapper
    return frappe.local.request_cache[func][args_key]
KeyError: -2033177531763587219

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 416, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 262, in install_app
    app_hooks = frappe.get_hooks(app_name=name)
  File "apps/frappe/frappe/__init__.py", line 1494, in get_hooks
    hooks = _dict(_load_app_hooks(app_name))
  File "apps/frappe/frappe/utils/caching.py", line 57, in wrapper
    return_val = func(*args, **kwargs)
  File "apps/frappe/frappe/__init__.py", line 1466, in _load_app_hooks
    app_hooks = get_module(f"{app}.hooks")
  File "apps/frappe/frappe/__init__.py", line 1328, in get_module
    return importlib.import_module(modulename)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'hrms'

I currently don’t have any kind of custom app. Kindly advice

execute

ls -1 apps > sites/apps.txt

Then try installing app

Hello there
After a few hours of testing and breaking stuff, installing the HRMS module seems to ruin everything. I am not sure what the problem is, but so far, it works fine; this is after I reset my docker setup. I have no idea why.

Do you suggest any method for adding a proxy domain in a production environment?

I want to access my website via its local domain but traefik returns 404. Then I added my local domain to frontend container label traefik.http.routers.frontend-http.rule, now nginx returns a 404. I ran bench setup add-domain [local-domain] --site [remote-domain] , then bench setup nginx and service nginx reload. Still getting that 404, but now from nginx. I tried opening nginx logs as root but they are blank…

I’m quite new to this setup, so forgive me if I’m missing something obvious here.
Thanks!

Check this out

Note:

Use python version 3.10.12 instead of 3.10.5. because of the older version is degraded

--build-arg=PYTHON_VERSION=3.10.12 \
1 Like

when i trying to installing app into site:
docker compose --project-name erpnext-one exec backend bench new-site ziptor.com --no-mariadb-socket --install-app lms

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 74, in new_site
    _new_site(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 80, in _new_site
    install_db(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 156, in install_db
    setup_database(force, source_sql, verbose, no_mariadb_socket)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/__init__.py", line 20, in setup_database
    return frappe.database.mariadb.setup_db.setup_database(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py", line 41, in setup_database
    if force or (db_name not in dbman.get_database_list()):
                                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/db_manager.py", line 49, in get_database_list
    return self.db.sql("SHOW DATABASES", pluck=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 260, in sql
    self.log_query(query, values, debug, explain)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 203, in log_query
    self.last_query = query = self._cursor._last_executed

Are you trying to install in the production mode?

yes im trying to install in the production mode.

No you shouldn’t install in production mode you have to take image build first from that image you have to up the containers.

1 Like

I followed your steps

Are you still facing issues ?

yes still facing. i followed your steps my os is windows 11