FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
02-18-2022 10:57 AM
Hello all,
I did a simple web server with Python Flask but when I create a .snap file, it does not include the static files (html, css, etc.). My question is how can I add external folders to my snapcraft yaml file ?
Solved! Go to Solution.
02-18-2022 11:27 AM - edited 02-18-2022 12:44 PM
Hello,
You can use a part in the snapcraft.yaml to dump the files you need into your snap.
This is an excerpt from the snapcraft.yaml of the python-sample webserver in the SDK (see it on GitHub) :
parts:
webserver:
plugin: python
source: .
configs:
plugin: dump
source: ./configs
organize:
'package-assets/*': package-assets/${SNAPCRAFT_PROJECT_NAME}/
www:
plugin: dump
source: ./www
Due to the last three lines snapcraft packs everything whats in the folder /www into your snap.
For more detailed information see:
Best regards,
Nick
02-18-2022 02:51 PM
Hi,
Thank you for the quick answer.
Yes, I actually tried this by taking this sample as a reference but it did not work. I am still getting an error "File not found". Here is the related part of my "snapcraft.yaml" file:
parts:
flask-app:
plugin: python
source: .
python-version: python3
requirements: [requirements.txt]
configs:
source: ./configs
plugin: dump
organize:
'package-assets/*': package-assets/${SNAPCRAFT_PROJECT_NAME}/
templates:
source: ./templates
plugin: dump
static:
source: ./static
plugin: dump
"templates" and "static" are the folders that I would like to include
Best, Deniz
02-21-2022 08:47 AM
Hello,
I just modified the webserver example with the snapcraft.yaml you send me and added the two folder with two test text files inside. And in my test the files get dumped into the snap.
Are you really sure, the files in the folders "templates" and "static" get not packed into your snap?
You can check that by unpacking the snap like a .zip archive. Maybe the path you are using in your application is not correct.
Best regards,
Nick
02-21-2022 12:18 PM
Hi,
I added the folders manually by unzipping the .snap file and zip it again. However, it still did not work 🙂
I realized that the CtrlX core is serving the application from the different root directory ("/var/snap") and did not copy my files and folders to that directory
02-21-2022 02:52 PM
Hi,
to clarify some things:
But to have the files inside of your snap should work for you. And the way to do it is with parts in the snapcraft.yaml, like I mentioned above.
If this still doesn't work for you, you can write me a private message with your contact data and we can find a way how I can give you personal support.
Best regards,
Nick