ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

How to add custom app to frappe docker / production installation

Hi,

i’ve spend the last few weeks customizing ERPNext to our needs. Alle customizations are put into a seperate app. After testing everything i now want to setup a production installation with docker. For testing installations i used pipechs docker images which worked flawlesly. Installing the app in development mode where done with:

bench get-app <git-url>
bench install-app <app_name>

For production installation i would like to use frappe_docker. I got v12 setup without any big issues, but i don’t get it how to add a custom app via docker-compose/dockerfiles. I followed the Custom apps description found in the git-Repository creating the directories and dockerfiles. Also confuring the shell scripts etc. But i always end with the same issue, that the setup fails when it tries to install the app, as it is always missing. It seems it is not picking up the created files.

For setup i call:
docker-compose --project-name <project_name> up -d

Manually adding file doesn’t work either:

docker-compose --project-name "<project_name>" --project-directory . up -d \
        -f installation/docker-compose-frappe.yml \
        -f installation/docker-compose-erpnext.yml \
        -f installation/docker-compose-<app_file>.yml \
        -f installation/docker-compose-common.yml

The only way i found getting the app installed, is by shelling into the erpnext-python container and manually installing the app by calling:

install_app <app_name> <git_url>
echo -n "\n<app_name>" >> sites/apps.txt
bench --site <site_name> install-app <app_name>

But i don’t know how to add those calls to the existing setup-pipeline. Running those steps manually doesn’t seem to be a good idea for production installs.

Would be cool if someone can shed some light on how to do setup correctly.

Regards

Kevin

unfortunately the following error on my instance
root@32d40c9cfc97:/home/frappe/frappe-bench# install_app ebclocal https://gitee.com/xxxxx.git
Cloning into ‘EBCLocal’…
remote: Enumerating objects: 58, done.
remote: Counting objects: 100% (58/58), done.
remote: Compressing objects: 100% (50/50), done.
remote: Total 58 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (58/58), done.
ERROR: /home/frappe/frappe-bench/apps/ebclocal is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with svn+, git+, hg+, or bzr+).
WARNING: You are using pip version 20.1.1; however, version 20.2.4 is available.
You should consider upgrading via the ‘/home/frappe/frappe-bench/env/bin/python -m pip install --upgrade pip’ command.
root@32d40c9cfc97:/home/frappe/frappe-bench# echo -n “\nebclocal” >> sites/apps.txt
root@32d40c9cfc97:/home/frappe/frappe-bench# bench --site erpnext.xin install-app ebclocal
An error occurred while installing ebclocal:
No module named ‘\nebclocal’
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 18, in
[sys.executable, bench_helper, ‘frappe’] + sys.argv[1:],
File “/opt/bitnami/python/lib/python3.7/subprocess.py”, line 363, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/home/frappe/frappe-bench/env/bin/python’, ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘frappe’, ‘–site’, ‘erpnext.xin’, ‘install-app’, ‘ebclocal’]’ returned non-zero exit status 1.

I have the same problem like @mindcry, custom app is not created.

Following the instructions, I created 2 directories, 2 Dockerfile, copied install_app.sh and so on:

Dockerfile …/telebot-worker

FROM frappe/erpnext-worker:edge

RUN install_app telebot https://github.com/yrestom/erpnext_telegram.git master
# Only add the branch if you are using a specific tag or branch.

Dockerfile …/telebot-nginx

FROM bitnami/node:12-prod

COPY build/telebot-nginx/install_app.sh /install_app

RUN /install_app telebot https://github.com/yrestom/erpnext_telegram.git master

FROM frappe/erpnext-nginx:edge

COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
COPY --from=0 /rsync /rsync
RUN echo -n "\ntelebot" >> /var/www/html/apps.txt

VOLUME [ "/assets" ]

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

docker-compose-telebot.yml

version: '3'

services:
  telebot-assets:
    image: telebot-assets
    build:
      context: ../build/telebot-nginx
    restart: on-failure
    environment:
      - FRAPPE_PY=telebot-python
      - FRAPPE_PY_PORT=8000
      - FRAPPE_SOCKETIO=frappe-socketio
      - SOCKETIO_PORT=9000
      - LETSENCRYPT_HOST=${SITES}
      - VIRTUAL_HOST=${SITES}
      - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
    depends_on:
      - telebot-python
      - frappe-socketio
      - frappe-worker-default
      - frappe-worker-long
      - frappe-worker-short
    links:
      - telebot-python
      - frappe-socketio
      - frappe-worker-default
      - frappe-worker-long
      - frappe-worker-short
    volumes:
      - sites-vol:/var/www/html/sites:rw
      - assets-vol:/assets:rw

  telebot-python:
    image: telebot-worker
    build:
      context: ../build/telebot-worker
    restart: on-failure
    environment:
      - MARIADB_HOST=${MARIADB_HOST}
      - REDIS_CACHE=redis-cache:6379
      - REDIS_QUEUE=redis-queue:6379
      - REDIS_SOCKETIO=redis-socketio:6379
      - SOCKETIO_PORT=9000
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
      - logs-vol:/home/frappe/frappe-bench/logs:rw
      - assets-vol:/home/frappe/frappe-bench/sites/assets:rw

  frappe-socketio:
    image: frappe/frappe-socketio:${FRAPPE_VERSION}
    restart: on-failure
    depends_on:
      - redis-socketio
    links:
      - redis-socketio
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
      - logs-vol:/home/frappe/frappe-bench/logs:rw

  frappe-worker-default:
    image: telebot-worker
    restart: on-failure
    command: worker
    depends_on:
      - redis-queue
      - redis-cache
    links:
      - redis-queue
      - redis-cache
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
      - logs-vol:/home/frappe/frappe-bench/logs:rw

  frappe-worker-short:
    image: telebot-worker
    restart: on-failure
    command: worker
    environment:
      - WORKER_TYPE=short
    depends_on:
      - redis-queue
      - redis-cache
    links:
      - redis-queue
      - redis-cache
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
      - logs-vol:/home/frappe/frappe-bench/logs:rw

  frappe-worker-long:
    image: telebot-worker
    restart: on-failure
    command: worker
    environment:
      - WORKER_TYPE=long
    depends_on:
      - redis-queue
      - redis-cache
    links:
      - redis-queue
      - redis-cache
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
      - logs-vol:/home/frappe/frappe-bench/logs:rw

  frappe-schedule:
    image: telebot-worker
    restart: on-failure
    command: schedule
    depends_on:
      - redis-queue
      - redis-cache
    links:
      - redis-queue
      - redis-cache
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
      - logs-vol:/home/frappe/frappe-bench/logs:rw

volumes:
  assets-vol:
  sites-vol:
  logs-vol:

And run: docker-compose --project-name site up -d

What am I doing wrong?

Revant @revant_one , I hope for your help. I spent on the solution of this problem more than a day :frowning:

I can’t help much, It is all trial-and-error just like everything else.

refer this app if it helps https://gitlab.com/castlecraft/excel_erpnext. It has docker directory and .gitlab-ci.yml that does the builds.

I am ready to trial-and-error, but why does the build do not picking up the created files? Or is the configuration incorrect?

run both the containers with bash interactively and inspect what files got created

Change the install_app.sh if required.

Check what install_app from frappe-worker does, add your own install_app in worker image as well if required.

@mindcry What are pipechs docker images? I will also try on my end and see how to install the custom apps. Thanks.

Hi @4elentano. Did you manage to solve this?