Back

Functions System Requirements

  • 0
  • Self Hosted
  • Functions
Ewyn
2 Sep, 2024, 13:27

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:

TypeScript
  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?
TL;DR
Developers are seeking help on adding texlive requirements to their container for a function. The issue arises due to the container being deleted and recreated as needed, causing software installations to be lost. A potential solution is to build binary files during the build step or run a bash script with `apt` to install dependencies during cold-start. An option to make the installation permanent is not provided, but a workaround is suggested to focus on ensuring the function works before addressing persistence. To add the texlive requirement to a Python container, the user added texlive via `apt` within the container. The error occurred due to missing the `/usr/bin
Ewyn
2 Sep, 2024, 13:27

do i have to create my own container? can i add the requirement differently?

Meldiron
2 Sep, 2024, 13:29

Heyy πŸ‘‹ May I ask, how did you add texlife to your python container?

Ewyn
2 Sep, 2024, 13:29

i went into the python container with docker exec and installed texlive via apt

Ewyn
2 Sep, 2024, 13:30

i know this would probably reset on updates or server restart but i just want the function to work first.

Ewyn
2 Sep, 2024, 13:30

i would also need to know how to make a permanent solution for this requirement

Meldiron
2 Sep, 2024, 13:31

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
Ewyn
2 Sep, 2024, 13:31

wait, i did not restart the appwrite instance after adding it. would it disappear when i restart the appwrite server?

Meldiron
2 Sep, 2024, 13:32

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

Meldiron
2 Sep, 2024, 13:32

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

Ewyn
2 Sep, 2024, 13:33

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

Meldiron
2 Sep, 2024, 13:34

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?

Meldiron
2 Sep, 2024, 13:34

or @Ebenezer Don maybe

Meldiron
2 Sep, 2024, 13:34

cc @Evdog too

Aditya Oberai
2 Sep, 2024, 13:35
Ewyn
2 Sep, 2024, 13:36

you are rightm the container deosnt exist anymore

Meldiron
2 Sep, 2024, 13:39

aaah, thanks!

Meldiron
2 Sep, 2024, 13:39

@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

Meldiron
2 Sep, 2024, 13:40

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)

Ewyn
2 Sep, 2024, 13:41

thank you, ima have a look at this

Ewyn
2 Sep, 2024, 13:42

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

Ewyn
2 Sep, 2024, 13:42

i will just add both into my file and let you guys know if it works out!

thanks for your help!

Ewyn
2 Sep, 2024, 13:57

@Meldiron Could i make my own container with texlive and have the Function use that?

Ewyn
2 Sep, 2024, 13:58

would that be more complicated or even possible?

Ewyn
2 Sep, 2024, 13:58
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more