Hello there! I have a function i use to create PDFΒ΄s. i use latex to create a template and generate the PDFs. heres the thing:
ive added texlive into my server in the Docker Container for python, but i still get this error:
File "/usr/local/server/src/server.py", line 163, in action
output = await asyncio.wait_for(execute(context), timeout=safeTimeout)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
return fut.result()
File "/usr/local/server/src/server.py", line 156, in execute
output = userModule.main(context)
File "/usr/local/server/src/function/entrypoint.py", line 14, in main
return generatePDF.generatepdf()
File "/usr/local/server/src/function/generatePDF.py", line 158, in generatepdf
result = subprocess.run(
File "/usr/local/lib/python3.9/subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/lib/python3.9/subprocess.py", line 1837, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/pdftex'```
How would i add that requirement into my self hosted appwrite?
do i have to create my own container? can i add the requirement differently?
Heyy π May I ask, how did you add texlife to your python container?
i went into the python container with docker exec and installed texlive via apt
i know this would probably reset on updates or server restart but i just want the function to work first.
i would also need to know how to make a permanent solution for this requirement
Ah, got it. Sadly those cotnainers for serverless functions gets deleted and created as needed, to save resources. Next time it spawned, it likely lost the installation. It could be solved by overwriting image itself, but that will be auto-pulled once executor restarts - it ensures latest runtime version is running.
My perosnal reocmmendation would be to do one of:
- Build binary file during build step, and then use it during runtime
- As part of function cold-start, run bash script with
apt
to install the dependency - first execution will be that much slower, but everything else will work quick
wait, i did not restart the appwrite instance after adding it. would it disappear when i restart the appwrite server?
It will be gone when you restart Open Runtimes Executor, which is part of Appwrite stack. Alternativelly it also stops after some inactivity, which is 10 or 15 mins by default when self-hosting
you can try to docker exec
into it again, and try to run the your commands - see if hey work or not. that can help idenfity if its sitll installed
do you have any recources for me for this problem? iΒ΄d have no clue where i would start with this. any pointers into the right direction would be appreciated
I knew there is one function example that does screenshot of website inside Node function of Appwrite. And it had same problem - it needs chromium installed. So it installed it as part of cold-start. But as much as I want to find it, I cant..
I think @Aditya Oberai made it, maybe he knows?
or @Ebenezer Don maybe
cc @Evdog too
This project achieved it
https://builtwith.appwrite.io/projects/6515cf7d341b8d10a5d4/
you are rightm the container deosnt exist anymore
aaah, thanks!
@Ewyn Check this out: https://github.com/dishwasher-detergent/screenshot/blob/main/functions/screenshot/src/main.ts#L38-L45
atthe beginning of your function you can run installation command. and have bool variable so it only runs once
https://github.com/dishwasher-detergent/screenshot/blob/main/appwrite.json#L18
Those are build commands set in function settings, to install them
(what i linked before just copies them to activate them, so its quick. Real installation happens during build)
thank you, ima have a look at this
as of rn i get Return statement missing. return context.res.empty() if no response is expected
but i expect i get this because i have no return
i will just add both into my file and let you guys know if it works out!
thanks for your help!
@Meldiron Could i make my own container with texlive and have the Function use that?
would that be more complicated or even possible?
https://hub.docker.com/r/texlive/texlive
smth like this
Recommended threads
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...