Closed sorinpopescu closed 2 months ago
I have the same issue, however for me it's that either the browser loads old assets after running bench build
or it can load js
assets fine but css
assets raise a 404
. I'm using frappe_docker to run frappe v14.66.3
and erpnext v14.64.0
.
Looks like removing the container and starting it as explained here fixes the issue.
You should not run bench build
command in docker production setup. Apps will be build during docker image build, there is no need and running bench build will break your site. Deleting and redeploying the current containers will solve the issue(docker compose down && docker compose up -d)
This issue has been automatically marked as stale. You have a week to explain why you believe this is an error.
@letajmal but rebuilding image with adding new or removing old apps will also break the site. It updates the sites/
directory which is mapped to a shared volume. If we remove this volume all data will be lost, if we keep it - we'll get a 500 (Internal Server Error).
So how should we add/remove/update apps on a working production docker containers?
Building a new image with the latest apps will not update anything under the sites folder.
What's happening in the docker image is they're just initialising a bench and get-app the required apps.
Once the new image is built, you just need to migrate and clear cache for the changes to rollout into your production site
it will be as follows
docker build
# Replace the image name with the latest tag in your compose file
docker compose up -d
bench migrate
bench clear cache
@letajmal thank you. But what if I need to add new app? Or remove unused one?
Remove that app from apps.json or from Dockerfile.
we are only keeping sites and logs directory as docker volumes, all the other directories are ephemeral/non persistent
The old application will get removed once you deploy the new image
You can uninstall the app from your site after that
@letajmal previously you said that
Building a new image with the latest apps will not update anything under the sites folder.
But information about all assets is stored in sites/assets/assets.json
so after building new frappe+erpnext docker image the frontend will look for old asset files like assets/frappe/dist/css/website.bundle.BHRNN4K5.css
that are listed in sites/assets/assets.json
and will not find them, because those build hashes changed (as well as file contents).
Please help to solve this issue.
So I had to start a new container (from newly built image) with shell, copy the contents of sites/assets/assets.json
and sites/assets/assets-rtl.json
, then go to my mapped sites/assets
volume and update those files in mapped volume, then bench clear-cache && bench clear-website-cache
, restarted my containers and now everything works fine.
By the way, the apps.json
file will also never be updated because it is located in sites
directory
@letajmal but sites/assets/assets.json
and sites/apps.json
are not.
So I had to start a new container (from newly built image) with shell, copy the contents of
sites/assets/assets.json
andsites/assets/assets-rtl.json
, then go to my mappedsites/assets
volume and update those files in mapped volume, thenbench clear-cache && bench clear-website-cache
, restarted my containers and now everything works fine.
I am sorry if i mislead you, these files will also get updated. For an example, from the official docs
apps.txt This file contains a list of Frappe apps. An app should be listed here before it can be installed on a site. It is added automatically when bench get-app command or bench new-app command is run.
so apps.txt will get updated when the we bench get-app during a docker image build refer line 105
RUN bench init \ --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 && \ bench get-app --branch=${ERPNEXT_BRANCH} --resolve-deps erpnext ${ERPNEXT_REPO} && \ echo "{}" > sites/common_site_config.json && \ find apps -mindepth 1 -path "*/.git" | xargs rm -fr
I assume all the other files you mentioned will also get updated during this step. May be someone with deep frappe framework knowledge can help us out here
Generally you should not worry about this, I have not came across any kinds of errors related to this
So I had to start a new container (from newly built image) with shell, copy the contents of
sites/assets/assets.json
andsites/assets/assets-rtl.json
, then go to my mappedsites/assets
volume and update those files in mapped volume, thenbench clear-cache && bench clear-website-cache
, restarted my containers and now everything works fine.
these files are already present in frappe/erpnext image even before creating a new site
Yes, and they are moved to docker shared volume. So after building new docker image and running a new container those files will not be updated.
After version change and containers rebuild assets are broken
Context information (for bug reports)
Steps to reproduce the issue
Expected result: after upgrade to have a fully functional application
Stacktrace / full error message if available