Closed smmitc closed 2 years ago
I'm able to save website theme on my kubernetes setup
it may be because the pod initContainer copies all js assets from nginx image into assets in sites volume.
may be you can try something like this if it works?
https://gist.github.com/revant/6a67f775aa8198f9b306f32d6872799f#file-erpnext-v13-yaml-L177-L189
I have the same problem with my kubernetes setup using the official chart. Then I've tested the setup using docker with the same results. The initContainer of gunicorn is:
initContainers:
- args:
- /usr/share/nginx/html/assets
- /home/frappe/frappe-bench/sites
command:
- cp
- -fR
image: frappe/erpnext-nginx:v14.0.3
imagePullPolicy: IfNotPresent
name: populate-assets
resources: {}
securityContext:
capabilities:
add:
- CAP_CHOWN
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /home/frappe/frappe-bench/sites/assets
name: assets-cache
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-jvmdx
readOnly: true
I tried the suggested commands in docker. There is no /data directory:
docker exec -it example-frontend-1 /bin/sh
/ $ ls
bin docker-entrypoint.sh lib opt run sys var
dev etc media proc sbin tmp
docker-entrypoint.d home mnt root srv usr
The sites volume is mounted to /usr/share/nginx/html/sites
and it contains a directory named assets
. So the correct command is cp -fR /usr/share/nginx/html/assets /usr/share/nginx/html/sites
, right? But then I get the error
cp: can't create '/usr/share/nginx/html/sites/assets/assets.json': Permission denied
cp: can't create '/usr/share/nginx/html/sites/assets/assets-rtl.json': Permission denied
cp: can't create directory '/usr/share/nginx/html/sites/assets/erpnext': Permission denied
cp: can't create directory '/usr/share/nginx/html/sites/assets/frappe': Permission denied
cp: can't create directory '/usr/share/nginx/html/sites/assets/payments': Permission denied
the commands run in separate container called populate-assets, you need to execute docker run
with appropriate -v
volume mounted in mentioned locations.
docker exec
executes command in existing container.
Thanks! The commands are working with docker run
if I run them as root with --user 0
.
docker run --rm --name populate_assets --user 0 \
> -v frappe_docker_assets:/data/assets:rw \
> -v frappe_docker_sites:/data/sites:rw \
> frappe/erpnext-nginx:v14.0.3 sh -c "cp -fR /usr/share/nginx/html/assets /data; touch /data/sites/.build";
Unfortunately that does not solve my problem.
as root with
--user 0
then you can chown
as required?
I didn't use chown. If I execute the commands as default user I get a lot of errors:
...
cp: can't create '/data/assets/erpnext/js/contact.js': File exists
cp: can't create '/data/assets/erpnext/js/shopping_cart.js': File exists
cp: can't create '/data/assets/erpnext/js/website_theme.js': File exists
cp: can't create '/data/assets/erpnext/js/communication.js': File exists
cp: can't create '/data/assets/erpnext/js/financial_statements.js': File exists
cp: can't create '/data/assets/erpnext/js/agriculture/ternary_plot.js': File exists
cp: can't create '/data/assets/erpnext/js/bank_reconciliation_tool/dialog_manager.js': File exists
cp: can't create '/data/assets/erpnext/js/bank_reconciliation_tool/data_table_manager.js': File exists
cp: can't create '/data/assets/erpnext/js/bank_reconciliation_tool/number_card.js': File exists
cp: can't create '/data/assets/erpnext/js/utils.js': File exists
cp: can't create '/data/assets/erpnext/js/account_tree_grid.js': File exists
cp: can't create '/data/assets/payments/node_modules/.yarn-integrity': File exists
cp: can't create '/data/assets/payments/.gitkeep': File exists
cp: can't create '/data/assets/payments/js/razorpay.js': File exists
Probably that's because /data/assets is owned by root:
docker run --rm --name populate_assets \
-v frappe_docker_assets:/data/assets:rw \
-v frappe_docker_sites:/data/sites:rw \
frappe/erpnext-nginx:v14.0.3 sh -c "ls -la /data/assets"
total 28
drwxr-xr-x 5 root root 4096 Sep 2 07:09 .
drwxr-xr-x 4 root root 4096 Sep 2 13:14 ..
-rw-r--r-- 1 root root 996 Sep 2 07:09 assets-rtl.json
-rw-r--r-- 1 root root 2980 Sep 2 07:09 assets.json
drwxr-xr-x 8 root root 4096 Sep 2 07:10 erpnext
drwxr-xr-x 11 root root 4096 Sep 1 07:11 frappe
drwxr-xr-x 4 root root 4096 Sep 2 07:10 payments
Oh, you want me to execute this, right?
docker run --rm --name populate_assets --user 0 \
-v frappe_docker_assets:/data/assets:rw \
-v frappe_docker_sites:/data/sites:rw \
frappe/erpnext-nginx:v14.0.3 sh -c "cp -fR /usr/share/nginx/html/assets /data; touch /data/sites/.build; chown -R 1000:1000 /data/assets";
The error ist still the same. Are the commands above correct?
Does nobody else have this problem? It's a complete new environment created by the commands in my first post.
We are also facing this issue. @revant any possible fix for this?
can you try building the assets image like this? https://github.com/frappe/frappe_docker/issues/919#issuecomment-1239305640
I think solved it for me. If that works, I'll remove frappe/assets-builder and update documentation to build assets using frappe/bench
Thank you very much, that solved the issue for me! :thumbsup: Now finally I'm able to use ERPNext v14 :smiley:
Description of the issue
With ERPNext v14 I'm not able to create a new Website Theme. I've tested Versions up to 14.0.3.
Context information (for bug reports)
Installation of the test environment:
Steps to reproduce the issue
Observed result
Expected result
New Website Theme without errors.
Stacktrace / full error message if available
Someone solved this issue in this post by doing
However as far as I know this has to be done when creating the image.