Custom App Docker Image Build Error

I am getting this error when I try to create Dicker image using the custom/Dockerfile under frappe/frappe_docker repo

Running build command for test_app
215.0 $ cd frontend && yarn build
215.0 $ vite build --base=/assets/test_app/frontend/ && yarn run copy-html-entry
215.0 vite v5.1.4 building for production...
215.0 transforming...
215.0 ✓ 18 modules transformed.
215.0 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
215.0 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
215.0 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
215.0 subprocess.CalledProcessError: Command 'bench build' returned non-zero exit status 1.
215.0
215.0 The above exception was the direct cause of the following exception:
215.0
215.0 Traceback (most recent call last):
215.0   File "/usr/local/lib/python3.11/site-packages/bench/commands/make.py", line 75, in init
215.0     init(
215.0   File "/usr/local/lib/python3.11/site-packages/bench/utils/render.py", line 105, in wrapper_fn
215.0     return fn(*args, **kwargs)
215.0            ^^^^^^^^^^^^^^^^^^^
215.0   File "/usr/local/lib/python3.11/site-packages/bench/utils/system.py", line 112, in init
215.0     build_assets(bench_path=path)
215.0   File "/usr/local/lib/python3.11/site-packages/bench/utils/bench.py", line 376, in build_assets
215.0     exec_cmd(command, cwd=bench_path, env=env)
215.0   File "/usr/local/lib/python3.11/site-packages/bench/utils/__init__.py", line 169, in exec_cmd
215.0     raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
215.0 bench.exceptions.CommandFailedError: bench build
215.0
215.0 ERROR: There was a problem while creating /home/frappe/frappe-bench
215.0 Do you want to rollback these changes? [y/N]:
------
Containerfile:110
--------------------
 109 |     ARG FRAPPE_PATH=https://github.com/frappe/frappe
 110 | >>> RUN export APP_INSTALL_ARGS="" && \
 111 | >>>   if [ -n "${APPS_JSON_BASE64}" ]; then \
 112 | >>>     export APP_INSTALL_ARGS="--apps_path=/opt/frappe/apps.json"; \
 113 | >>>   fi && \
 114 | >>>   bench init ${APP_INSTALL_ARGS}\
 115 | >>>     --frappe-branch=${FRAPPE_BRANCH} \
 116 | >>>     --frappe-path=${FRAPPE_PATH} \
 117 | >>>     --no-procfile \
 118 | >>>     --no-backups \
 119 | >>>     --skip-redis-config-generation \
 120 | >>>     --verbose \
 121 | >>>     /home/frappe/frappe-bench && \
 122 | >>>   cd /home/frappe/frappe-bench && \
 123 | >>>   echo "{}" > sites/common_site_config.json && \
 124 | >>>   find apps -mindepth 1 -path "*/.git" | xargs rm -fr
 125 |
--------------------
ERROR: failed to solve: process "/bin/sh -c export APP_INSTALL_ARGS=\"\" &&   if [ -n \"${APPS_JSON_BASE64}\" ]; then     export APP_INSTALL_ARGS=\"--apps_path=/opt/frappe/apps.json\";   fi &&   bench init ${APP_INSTALL_ARGS}    --frappe-branch=${FRAPPE_BRANCH}     --frappe-path=${FRAPPE_PATH}     --no-procfile     --no-backups     --skip-redis-config-generation     --verbose     /home/frappe/frappe-bench &&   cd /home/frappe/frappe-bench &&   echo \"{}\" > sites/common_site_config.json &&   find apps -mindepth 1 -path \"*/.git\" | xargs rm -fr" did not complete successfully: exit code: 1

What could be the probable cause of this error?

I narrowed this down to having problem while running cp command within yarn run during a docker build execution

I found the problem.

Basically you have to make a www directory within the custom app folder, since cp command doesn’t create new directories.

I dont know why its not created during the docker build step.
I modified:

...
"copy-html-entry": "mkdir ../test_app/www && cp ../test_app/public/frontend/index.html ../test_app/www/frontend.html"
...

And this works.