Google App Engine OSError: cannot load library 'libsndfile.so' - python-3.x

I get the following error from Google App Engine after completing a docker push.
OSError: cannot load library 'libsndfile.so': libsndfile.so: cannot open shared object file: No such file or directory
My docker file has the following:
RUN apt-get update && apt-get install -y \
build-essential \
software-properties-common \
ffmpeg \
libsndfile1-dev \
&& rm -rf /var/lib/apt/lists/*
Which should get that library. I also found that pip installing soundfile might also fix it but that did not work either.
I am pushing a Streamlit app if that helps at all.

I'm not sure if it'll be solved, but why don't you add gcc?
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
software-properties-common \
ffmpeg \
libsndfile1-dev \
&& rm -rf /var/lib/apt/lists/*

Related

apk not found error while changing to node-buster from Alpine base image

I have changed my image in docker from Alpine base image to node:14.16-buster, While running the code I am getting 'apk not found' error.
Sharing the codes snippet :
FROM node:14.16-buster
# ========= steps for Oracle instant client installation (start) ===============
RUN apk --no-cache add libaio libnsl libc6-compat curl && \
cd /tmp && \
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
unzip instantclient-basiclite.zip && \
mv instantclient*/ /usr/lib/instantclient && \
rm instantclient-basiclite.zip
Can you please help here, what do I need to change?
The issue comes from the fact that you're changing your base image from Alpine based to Debian based.
Debian based Linux distributions use apt as their package manager (Alpine uses apk).
That is the reason why you get apk not found. Use apt install, but also keep in mind that the package names could differ and you might need to look that up. After all, apt is a different piece of software with it's own capabilities.
Buster images are based on the Debian version.
It doesn't support the APK default package manger is APT
For example you can do :
FROM node:15.14.0-buster-slim
RUN apt-get update && \
apt-get install -y \
curl \
jq \
git \
wget \
openssl \
bash \
tar \
net-tools && \
rm -rf /var/lib/apt/lists/*
RUN mkdir /app && \
chown node:node /app
APK is part of the Linux alpine version you have to change the base version if you want to use the APK.
The buster node images are Debian based. buster is the release name for Debian 10 (11 will be bullseye).
Debian uses APT for packaging. apt-get can be used from scripts
apt-get update && apt-get install libaio1 curl
libnsl2 is not available in Buster, but you might not need it

Optimize docker image build size with curl

I need to install on docker the latest version of curl
when using the following the docker size is ~140MB
FROM debian:10.7
RUN apt-get update && \
apt-get install --no-install-recommends -y curl wget ca-certificates
This use curl 7.64
when using the following
FROM debian:10.7
RUN apt-get update && \
apt-get install --yes --no-install-recommends wget build-essential ca-certificates libcurl4 && \
wget https://curl.se/download/curl-7.73.0.tar.gz && \
tar -xvf curl-7.73.0.tar.gz && cd curl-7.74.0 && \
./configure && make && make install && \
apt-get purge -y --auto-remove build-essential && \
The docker image size is 240MB, I've tried to remove the build essintials which reduce the size from 440 to 240 , is there a way to remove this additional ~100MB ?
In fact, you are close to the solution. The one you missed is to delete the curl source package.
So next should make the image reduce:
FROM debian:10.7
RUN apt-get update && \
apt-get install --yes --no-install-recommends wget build-essential ca-certificates libcurl4 && \
wget https://curl.se/download/curl-7.73.0.tar.gz && \
tar -xvf curl-7.73.0.tar.gz && cd curl-7.73.0 && \
./configure && make && make install && \
apt-get purge -y --auto-remove build-essential && \
cd .. && rm -fr curl-7.73.0.tar.gz curl-7.73.0
Without Curl:
$ docker images abc:1
REPOSITORY TAG IMAGE ID CREATED SIZE
abc 1 d742bfdf5fa6 25 seconds ago 148MB
With curl & source package delete:
$ docker images abc:2
REPOSITORY TAG IMAGE ID CREATED SIZE
abc 2 afe3d404852a 27 minutes ago 151MB
Additional, if you delete apt cache with rm -rf /var/lib/apt/lists/* in Dockerfile, if will be smaller:
$ docker images abc:3
REPOSITORY TAG IMAGE ID CREATED SIZE
abc 3 5530b0e9b44f 2 minutes ago 134MB
Another solution maybe use multistage-build, you could use ./configure --prefix=xxx to set a default install location, then stage1 just used to build curl, while stage2 copy the xxx folder from stage1 to final image.
You should inclide rm -rf /var/lib/apt/lists/* into your RUN instruction to remove apt index files and might include apt-get clean to remove any other remaining package file.
Apart from that, you could also try using the slim image version, according to Docker Hub debian:10.7-slim is almost half size (~24Mb vs ~48Mb)
Finally, you can execute du -h | sort -h on a container from your generated image to find out where is the remaining space usage.
Using multistage-build as suggested by atline :
FROM debian:10.7 AS builder
WORKDIR /app
RUN mkdir /app/usr2
RUN apt-get update && \
apt-get install --yes --no-install-recommends wget build-essential ca-certificates libcurl4 && \
wget https://curl.se/download/curl-7.73.0.tar.gz && \
tar -xvf curl-7.73.0.tar.gz && cd curl-7.73.0 && \
./configure --prefix=/app/usr2 && make install
FROM debian:10.7
RUN apt-get update && \
apt-get install --no-install-recommends -y wget ca-certificates &&\
rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/usr2/. /usr
Final size is 129MB

How to modify default docker base image during deployment of Azure Kubernetes service

I have been using DEFAULT_GPU_IMAGE as my base image in Azure ML but now it started throwing the
ImportError: libGL.so.1: cannot open shared object file: No such file or directory error when importing opencv.
Some answers here on stackoverflow say i need to run apt-get update on the image. specifically:
RUN apt-get update ##[edited]
RUN apt-get install 'ffmpeg'\
'libsm6'\
'libxext6' -y
Would you know where can i find the docker file to add the lines to or is there a way to patch the image during the deployment of the AKS service? (same way as pip and conda packages are possible to be installed during the deployment)
The base images for AzureML containers can be found in this github project.
This page also contains detailed documentation for the images.
Alternatively you can use "docker inspect" to get details of the image.
For example: docker inspect mcr.microsoft.com/azureml/base-gpu:latest
Then in the base image like this dockerfile just add packages you need along with other dependencies like in this:
# custom packages <------
apt-get install -y \
ffmpeg \
libsm6 \
libxext6 && \
# Install Common Dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# SSH and RDMA
libmlx4-1 \
libmlx5-1 \
librdmacm1 \
libibverbs1 \
libmthca1 \
libdapl2 \
dapl2-utils \
openssh-client \
openssh-server \
iproute2 && \
# custom packages <------
apt-get install -y \
ffmpeg \
libsm6 \
libxext6 && \
# Others
apt-get install -y \
build-essential \
...

docker build error the folder you are executing pip from can no longer be found

I'm making a Dockerfile to install python38 on centos7 base. Everything works file until pip3 command. Dockerile looks like this.
FROM centos:centos7
RUN RPM_LIST=" \
gcc \
make \
openssl-devel \
bzip2-devel \
libffi-devel" && \
yum install -y $RPM_LIST && \
curl -O https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz && \
tar xvf Python-3.8.2.tgz && \
cd Python-3.8.2 && \
./configure && \
make && \
make install && \
rm -rf /Python-3.8.2* && \
yum remove -y $RPM_LIST && \
pip3 install retrying
Error is The folder you are executing pip from can no longer be found..
I changed the last line to RUN pip3 install retrying and it started working, but it added an additional 300 MB to my image, which i can't effort.
Any suggestions, what am i missing here or any alternative ways ?
This is how the working Dockerfile looks like
FROM centos:centos7
RUN RPM_LIST=" \
gcc \
make \
openssl-devel \
bzip2-devel \
libffi-devel" && \
yum install -y $RPM_LIST && \
curl -O https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz && \
tar xvf Python-3.8.2.tgz && \
cd Python-3.8.2 && \
./configure && \
make && \
make install && \
pip3 install retrying && \
yum remove -y $RPM_LIST && \
rm -rf /Python-3.8.2*
for some reason, calling pip3 command from Python-3.8.2 folder was not working. Here i moved the rm command after the pip3 call. Hope this information helps someone.
I just ran into The folder you are executing pip from can no longer be found.
My Dockerfile has not changed in months. It does not install pip.
It does force remove and make a folder just prior to running a pip install on a requirements file -- into which pip is supposed to install things.
The fix? I simply ran it again and it worked. Hmm...
So I am posting this here in case there is some mysterious timing issue about which folks wish to collect clues.
--- edit add --
Also, yesterday I ran into this docker issue, which required turning off docker's experimental gRPC feature in its preferences. Perhaps it could be related somehow?
Why does Serverless produce an Invalid Cross-device link Error when trying to package or deploy?

How to install chrome (headless) in linux

I have an AWS EC2 running linux redhad. Is there a way to install the latest Chrome v59 on it so that I can run it in headless mode just like PhantomJS? All the resources I can find in google are about how to install it in ubuntu which has a UI. My Linux doesn't have a UI.
Thanks
this question is kinda old, but someone may find the answer useful.
these commands install headless chrome in ubuntu:
apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
hicolor-icon-theme \
libcanberra-gtk* \
libgl1-mesa-dri \
libgl1-mesa-glx \
libpango1.0-0 \
libpulse0 \
libv4l-0 \
fonts-symbola \
--no-install-recommends \
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update && apt-get install -y \
google-chrome-stable \
--no-install-recommends \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /var/lib/apt/lists/*
set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
unzip \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL "https://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb" -o /tmp/google-talkplugin-amd64.deb \
&& dpkg -i /tmp/google-talkplugin-amd64.deb
ADD https://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb /src/google-talkplugin_current_amd64.deb
hope this helps someone
You might want to take a look at projects like chromeless or puppeteer which both offer a feature-rich API as well as documentation on running on most hosting providers.
Alternatively, if you're looking for something custom-built for this then I run a SaaS called browserless that attacks the problem directly.
In any case, hope that helps
Follow these steps for install chrome in linux machine,
Download .rpm file from Chrome official website.
click here for download chrome , download.rpm file.
Double click on .rpm file and install.

Resources