Docker setup - getting custom app into container

Hi,

I manage to get frappe/erpnext installed with using the docs found at GitHub - frappe/frappe_docker: Docker images for production and development setups of the Frappe framework and ERPNext

I used the standard .env file with below compose command

|-------------------------------------------------
git clone GitHub - frappe/frappe_docker: Docker images for production and development setups of the Frappe framework and ERPNext
cd frappe_docker
cp .\example.env .env

docker compose -f compose.yaml -f overrides/compose.erpnext.yaml -f overrides/compose.mariadb.yaml -f overrides/compose.redis.yaml -f overrides/compose.noproxy.yaml config > ~/gitops/docker-compose.yml

docker compose --project-name pema -f ~/gitops/docker-compose.yml up -d
------------------------------------------------------|
I also manage to get the containers up and was able to restore backups from production site

this obviously put the site on “Internal Server Error” with logs showing below from the backend container:

During handling of the above exception, another exception occurred:,
,
Traceback (most recent call last):,
File “/home/frappe/frappe-bench/env/lib/python3.9/site-packages/gunicorn/workers/gthread.py”, line 271, in handle,
keepalive = self.handle_request(req, conn),
File “/home/frappe/frappe-bench/env/lib/python3.9/site-packages/gunicorn/workers/gthread.py”, line 323, in handle_request,
respiter = self.wsgi(environ, resp.start_response),
File “/home/frappe/frappe-bench/env/lib/python3.9/site-packages/werkzeug/local.py”, line 231, in application,
return ClosingIterator(app(environ, start_response), self.cleanup),
File “/home/frappe/frappe-bench/env/lib/python3.9/site-packages/werkzeug/wrappers/base_request.py”, line 237, in application,
resp = f(*args[:-2] + (request,)),
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 90, in application,
response = handle_exception(e),
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 290, in handle_exception,
response = frappe.website.render.render(“message”, http_status_code=http_status_code),
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py”, line 54, in render,
elif is_static_file(path):,
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py”, line 127, in is_static_file,
file_path = frappe.get_app_path(app, “www”) + “/” + path,
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1227, in get_app_path,
return get_pymodule_path(app_name, *joins),
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1244, in get_pymodule_path,
return os.path.join(os.path.dirname(get_module(scrub(modulename)).file or “”), *joins),
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1200, in get_module,
return importlib.import_module(modulename),
File “/usr/local/lib/python3.9/importlib/init.py”, line 127, in import_module,
return _bootstrap._gcd_import(name[level:], package, level),
File “”, line 1030, in _gcd_import,
File “”, line 1007, in _find_and_load,
File “”, line 984, in _find_and_load_unlocked,
ModuleNotFoundError: No module named ‘trader’,


now I am trying to add my customer app to the container and this is where im stuck.

I tried to copy the app after cloning to local and copying it over to the container /home/frappe/frappe-bench/app folder

running bench --site mysite.co.za install-app trader
I get error that the app is not found

so then I tried to get through the steps from https://github.com/frappe/frappe_docker/tree/main/custom_app

I copied the files to the local app folder and updated the files as shown below:

frontend.Dockerfile →

ARG FRAPPE_VERSION
ARG ERPNEXT_VERSION

FROM frappe/assets-builder:${FRAPPE_VERSION} as assets

ARG APP_NAME
COPY ./apps/${APP_NAME} apps/${APP_NAME}
RUN install-app ${APP_NAME}

FROM frappe/erpnext-nginx:${ERPNEXT_VERSION}

COPY --from=assets /out /usr/share/nginx/html


backend.Dockerfile →

ARG ERPNEXT_VERSION
FROM frappe/erpnext-worker:${ERPNEXT_VERSION}

USER root

ARG APP_NAME
COPY . …/apps/${APP_NAME}

RUN --mount=type=cache,target=/root/.cache/pip
install-app ${APP_NAME}

USER frappe


docker-bake.hcl →

APP_NAME=“trader”

variable “FRAPPE_VERSION” {}
variable “ERPNEXT_VERSION” {}

group “default” {
targets = [“backend”, “frontend”]
}

target “backend” {
dockerfile = “backend.Dockerfile”
tags = [“trader/worker:latest”]
args = {
“ERPNEXT_VERSION” = ERPNEXT_VERSION
“APP_NAME” = APP_NAME
}
}

target “frontend” {
dockerfile = “frontend.Dockerfile”
tags = [“trader/nginx:latest”]
args = {
“FRAPPE_VERSION” = FRAPPE_VERSION
“ERPNEXT_VERSION” = ERPNEXT_VERSION
“APP_NAME” = APP_NAME
}
}



hemant@APTLPEMAHEM:~/frappe_dockers/apps/trader$ FRAPPE_VERSION=v13.36.1 ERPNEXT_VERSION=v13.36.0 docker buildx bake
[+] Building 36.5s (13/13) FINISHED
=> [frontend internal] load build definition from frontend.Dockerfile 0.9s
=> => transferring dockerfile: 333B 0.0s
=> [backend internal] load build definition from backend.Dockerfile 2.4s
=> => transferring dockerfile: 270B 0.0s
=> [frontend internal] load .dockerignore 2.0s
=> => transferring context: 2B 0.0s
=> [backend internal] load .dockerignore 2.5s
=> => transferring context: 2B 0.0s
=> [frontend internal] load metadata for docker.io/frappe/erpnext-nginx:v13.36.0 0.0s
=> ERROR [frontend internal] load metadata for docker.io/frappe/assets-builder:v13.36.1 34.1s
=> [backend internal] load metadata for docker.io/frappe/erpnext-worker:v13.36.0 0.0s
=> [backend internal] load build context 0.5s
=> => transferring context: 4.56kB 0.0s
=> CACHED [backend stage-0 1/3] FROM docker.io/frappe/erpnext-worker:v13.36.0 0.0s
=> [backend stage-0 2/3] COPY . …/apps/trader 0.8s
=> [backend stage-0 3/3] RUN --mount=type=cache,target=/root/.cache/pip install-app trader 6.6s
=> [auth] frappe/assets-builder:pull token for registry-1.docker.io 0.0s
=> [backend] exporting to image 3.6s
=> => exporting layers 1.4s
=> => writing image sha256:a27a605c2cc0568b53c9dd3a95a40cc69d4ca59d8a73e7ca5567af728dd25c60 0.1s
=> => naming to docker.io/trader/worker:latest 0.1s
[frontend internal] load metadata for docker.io/frappe/assets-builder:v13.36.1:

error: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to authorize: rpc error: code = Unknown desc = failed to fetch oauth token: Post “https://auth.docker.io/token”: dial tcp 44.207.51.64:443: i/o timeout


if I run docker images:
hemant@APTLPEMAHEM:~/frappe_dockers/apps/trader$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
trader/worker latest a27a605c2cc0 5 minutes ago 1.19GB
frappe/assets-builder latest 17fb5cf4aae3 18 hours ago 1.24GB
frappe/erpnext-nginx v13.36.0 a155b9eea655 26 hours ago 223MB
frappe/erpnext-worker v13.36.0 f61c76f351b2 26 hours ago 1.19GB
frappe/frappe-socketio v13.36.1 6457fac6fdca 26 hours ago 182MB
redis 6.2-alpine b6e4ce5f89f4 2 days ago 25.5MB
mariadb 10.6 bda4cf409ffc 6 weeks ago 413MB
portainer/portainer latest 980323c8eb3f 18 months ago 196MB


if I then run

docker-compose -f compose.yaml -f overrides/compose.noproxy.yaml -f overrides/compose.mariadb.yaml -f overrides/compose.redis.yaml -f apps/trader/compose.override.yaml up -d

Pulling frontend (trader/nginx:latest)…
ERROR: The image for the service you’re trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.

Continue with the new image? [yN]y
Pulling frontend (trader/nginx:latest)…
ERROR: pull access denied for trader/nginx, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied


not sure where I went wrong, but after all this I need a lil more assistance getting a customer app into the container - any assistance will be greatly appreciated. Thanking you in advance.

kind regards
Hemant

Do you have the answer? I am having the same problem as you.

Not sure about the exact problem here but I was able to setup ERPNext docker using my own custom images. Here is the simplified tutorial that you can use (Check readme): https://git.loniushealth.com/root/erp-docker-deploy

Edit the create-bench.yaml with your own images (frontend and backend)

1 Like

to build custom images as mentioned in official docs refer this example repo GitHub - castlecraft/custom_frappe_docker

1 Like

“Execute from root of app repo…”. Should I execute it in the project folder or in the app folder in the app’s package?

git clone https://github.com/castlecraft/custom_frappe_docker
cd custom_frappe_docker
# execute commands here
1 Like

Hi @revant_one

Thank you for the response

I tried the steps in the repo and sorry for my ignorance but after following the steps in the readme im getting the below error - not sure if I missed something in the install or config of docker. Im running docker desktop on windows wsl2 on an Ubuntu20

error: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: failed to authorize: rpc error: code = Unknown desc = failed to fetch oauth token: Post “https://auth.docker.io/token”: dial tcp 44.207.51.64:443: i/o timeout

any assistance would be greatly appreciated…thank you in advance.

I don’t have windows setup

Do you have access to any search engine?

Searching for the error resulted in Failed to authorize: rpc error: code = Unknown desc = failed to fetch oauth token: unexpected status: 401 Unauthorized - #40 by jercle - General - Docker Community Forums

Do you have a static IP?

@revant_one - I did search as you suggested, and even tried the link you posted…followed the thinking and steps but still getting errors, It must be something to do with authorisation key - but ill continue to search.

@tdci - im on a dynamic IP

Ill probibly tied this on another machine as the office machine might have some restrictions, and start from fresh and scratch.

did it work with you ?? am stuck at the same point

Hi

No it did not… I left it at that and went back to my virtualbox vm…so currently still using that for now. Will try docker again when I have more time to play around with it.