I need 2 packages for my Google Cloud Functions (GCF) functions to work properly. I'd typically install them with the following command on Ubuntu:
apt-get -y install firefox xvfb
However, I don't know anyway to package my functions which would direct GCF to download these packages before running my code.
I tried installing them from within my Python function, using subprocess.call().
Here is some code:
try:
print(subprocess.check_output("apt-get -y install firefox", shell=True, stderr=subprocess.STDOUT))
except subprocess.CalledProcessError as e:
print("Ping stdout output:\n", e.output)
try:
print(subprocess.check_output("apt-get -y install xvfb", shell=True, stderr=subprocess.STDOUT))
except subprocess.CalledProcessError as e:
print("Ping stdout output:\n", e.output)
Unfortunately, this does not work. I get the following errors:
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libcanberra0 libdbusmenu-gtk3-4 libstartup-notification0 libtdb1
libxcb-util1 sound-theme-freedesktop xul-ext-ubufox
Suggested packages:\n fonts-lyx libcanberra-gtk0 libcanberra-pulse
The following NEW packages will be installed: firefox
libcanberra0 libdbusmenu-gtk3-4 libstartup-notification0 libtdb1
libxcb-util1 sound-theme-freedesktop xul-ext-ubufox
0 upgraded, 8 newly installed, 0 to remove and 5 not upgraded.
Need to get 44.5 MB of archives.
After this operation, 170 MB of additional disk space will be used.
W: Not using locking for read only lock file /var/lib/dpkg/lock
W: chown to _apt:root of directory /var/cache/apt/archives/partial failed - SetupAPTPartialDirectory (30: Read-only file system)
W: chmod 0700 of directory /var/cache/apt/archives/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
W: chown to _apt:root of directory /var/lib/apt/lists/auxfiles failed - SetupAPTPartialDirectory (30: Read-only file system)
W: chmod 0700 of directory /var/lib/apt/lists/auxfiles failed - SetupAPTPartialDirectory (1: Operation not permitted)
W: Not using locking for read only lock file /var/cache/apt/archives/lock
E: Couldn't determine free space in /var/cache/apt/archives/ - statvfs (38: Function not implemented)
How can I fix this error to download the packages from within my python code? Is there any other (easier/cleaner) way to achieve what I'm trying to do?
Thanks!