-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get working precompiled binaries for Dlib/Pdlib on Alpine Linux #221
Comments
Possibly related to: Need to include that extra lib LAPACK? PKG_LIBS = |
Hmm, these build logs do report that the lapack package is not found, so that might be a possible cause. However, the Dlib docs imply that lapack is optional:
I'll try to build the package with lapack included to see if it makes a difference. Edit: sorry, forgot to include link to the build logs: https://build.alpinelinux.org/buildlogs/build-edge-x86_64/testing/dlib/dlib-19.18-r0.log |
For reference, here's a Dockerfile that I mashed up based on earlier comments by @matiasdelellis and some tweaking by me. The pdlib tests seem to run fine, even with lapack not installed 🤔 FROM alpine AS builder
# DLib https://github.com/goodspb/pdlib#dependencies
RUN apk add cmake make gcc libc-dev g++ unzip openblas-dev libx11-dev pkgconf jpeg jpeg-dev libpng libpng-dev
ARG DLIB_BRANCH=v19.19
RUN wget -c -q https://github.com/davisking/dlib/archive/${DLIB_BRANCH}.tar.gz \
&& tar xf ${DLIB_BRANCH}.tar.gz \
&& mv dlib-* dlib \
&& cd dlib/dlib \
&& mkdir build \
&& cd build \
&& cmake -DBUILD_SHARED_LIBS=ON --config Release .. \
&& make \
&& make install
# https://github.com/goodspb/pdlib#installation
RUN apk add php7-dev php7-gd
ENV PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig/
RUN pkg-config --libs --cflags libjpeg \
&& pkg-config --libs --cflags dlib-1
ARG PDLIB_BRANCH=master
RUN wget -c -q https://github.com/goodspb/pdlib/archive/$PDLIB_BRANCH.zip \
&& unzip $PDLIB_BRANCH \
&& mv pdlib-* pdlib \
&& cd pdlib \
&& phpize \
&& ./configure \
&& make \
&& make install
RUN echo "extension=pdlib.so" > /etc/php7/conf.d/pdlib.ini
# Download test and clean it
RUN wget https://github.com/matiasdelellis/facerecognition/files/3107912/crop-tests.zip \
; unzip -q crop-tests.zip \
; rm crop-tests/cropped_* \
; rm crop-tests/test.csv
# download models needed to test and execute it..
RUN cd crop-tests ; mkdir -p vendor/models/1/ \
; wget https://github.com/davisking/dlib-models/raw/94cdb1e40b1c29c0bfcaf7355614bfe6da19460e/mmod_human_face_detector.dat.bz2 -O vendor/models/1/mmod_human_face_detector.dat.bz2 \
; bzip2 -d vendor/models/1/mmod_human_face_detector.dat.bz2 \
; wget https://github.com/davisking/dlib-models/raw/2a61575dd45d818271c085ff8cd747613a48f20d/dlib_face_recognition_resnet_model_v1.dat.bz2 -O vendor/models/1/dlib_face_recognition_resnet_model_v1.dat.bz2 \
; bzip2 -d vendor/models/1/dlib_face_recognition_resnet_model_v1.dat.bz2 \
; wget https://github.com/davisking/dlib-models/raw/4af9b776281dd7d6e2e30d4a2d40458b1e254e40/shape_predictor_5_face_landmarks.dat.bz2 -O vendor/models/1/shape_predictor_5_face_landmarks.dat.bz2 \
; bzip2 -d vendor/models/1/shape_predictor_5_face_landmarks.dat.bz2 \
; php test.php |
Being a docker newbie I just added your code above to my exising Dockerfile - and ran the ansible playbook for the project.
|
I made the container without the tests.
which has to do with your line: At least in my setup the conf.d setup didn't work - but maybe it does - and just needs a machine restart... In fact in my setup - 16.04 ubuntu:
works on the cli (not tested in Dockerfile yet) |
@james-cook Thanks for taking the time to look into this! Sorry I haven't responded for a while. No matter what I try, I cannot reproduce the error you get. Can you try the following Dockerfile, build it with FROM nextcloud:17-fpm-alpine
ADD repositories /etc/apk
RUN apk --update upgrade
RUN apk add php7-pdlib
RUN echo 'extension=/usr/lib/php7/modules/pdlib.so' > /usr/local/etc/php/conf.d/pdlib.ini
RUN echo 'memory_limit=2048M' > /usr/local/etc/php/conf.d/memory-limit.ini
# Download test and clean it
RUN wget https://github.com/matiasdelellis/facerecognition/files/3107912/crop-tests.zip \
; unzip -q crop-tests.zip \
; rm crop-tests/cropped_* \
; rm crop-tests/test.csv
# download models needed to test and execute it..
RUN cd crop-tests ; mkdir -p vendor/models/1/ \
; wget https://github.com/davisking/dlib-models/raw/94cdb1e40b1c29c0bfcaf7355614bfe6da19460e/mmod_human_face_detector.dat.bz2 -O vendor/models/1/mmod_human_face_detector.dat.bz2 \
; bzip2 -d vendor/models/1/mmod_human_face_detector.dat.bz2 \
; wget https://github.com/davisking/dlib-models/raw/2a61575dd45d818271c085ff8cd747613a48f20d/dlib_face_recognition_resnet_model_v1.dat.bz2 -O vendor/models/1/dlib_face_recognition_resnet_model_v1.dat.bz2 \
; bzip2 -d vendor/models/1/dlib_face_recognition_resnet_model_v1.dat.bz2 \
; wget https://github.com/davisking/dlib-models/raw/4af9b776281dd7d6e2e30d4a2d40458b1e254e40/shape_predictor_5_face_landmarks.dat.bz2 -O vendor/models/1/shape_predictor_5_face_landmarks.dat.bz2 \
; bzip2 -d vendor/models/1/shape_predictor_5_face_landmarks.dat.bz2
#; php test.php
ENTRYPOINT ["php", "crop-tests/test.php"] For me, running this Dockerfile yields the |
I was able to get a working setup with the following Dockerfile: FROM nextcloud:18-fpm-alpine
RUN apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing dlib
RUN wget https://github.com/goodspb/pdlib/archive/master.zip \
&& mkdir -p /usr/src/php/ext/ \
&& unzip -d /usr/src/php/ext/ master.zip \
&& rm master.zip
RUN docker-php-ext-install pdlib-master
RUN apk add bzip2-dev
RUN docker-php-ext-install bz2 Let me break it down:
That's it. Granted, it's a little more involved than I anticipated, but still pretty easy to setup. The building of pdlib takes some time, but it's all automated by I'm in the process of updating Dlib to 19.19 in Alpine testing (current is 19.18). I'm also looking into ways to get Dlib into one of the stable repositories. |
Thank you very much for all the research and progress! 😄 😃 |
Hello everyone, This shouldn't affect them as much, but one of the things I hope to do is improve the documentation. For example, here is a first documentation about how to install PDlib on docker. Well, Insist in that I have no more experience with docker, 😅 therefore I want your opinion. 😄 Thanks, |
Hi Matias, this looks great! Thanks for your effort to document the Docker installation! If it's ok, I'll leave some feedback here.
I'm having some trouble reading this sentence. The multi-stage build feature is used only in the Debian example, not with Alpine (since Dlib doesn't need to be built in Alpine). My suggestion is to rephrase it to something like this: We are aware that many users use Docker for their Nextcloud instances.
Below are some examples and then some steps to help you quickly get started with Facerecognition using Docker.
There are two variants: Debian using Apache and Alpine using PHP FPM.
These are based on the two options available in https://github.com/nextcloud/docker
## Examples
### Extend nextcloud:apache
In this example we show how to install Dlib and PDlib from source to build a Nextcloud image with Debian and Apache.
This `Dockerfile` uses [multistage builds](https://docs.docker.com/develop/develop-images/multistage-build/) to first build the binaries of Dlib and then automatically copy the binaries to the final image.
Use it as a guide to adapt it to your needs.
(Dockerfile here)
### Extend nextcloud:18-fpm-alpine
In this example we show how to install Dlib from a repository and PDlib using [docker-php-ext-install](https://github.com/docker-library/php/) to build a Nextcloud image with Alpine and PHP FPM (for use with Nginx).
(Dockerfile here) |
Some feedback on the Dockerfiles: I've built the Dockerfile. For me it stopped at the
After this the image built with success and I was able to start it. The Alpine image also works fine, but shouldn't the pdlib URL be replaced with yours? (i.e. |
I'm also wondering: since the Apache base image uses Debian Buster, could it be possible that Dlib is already available as binary package via I looked around and found this: https://packages.debian.org/buster/libdlib19 |
Hi @agboom
Theoretically pdlib depends 19.13, but i will try to compile it 19.10 😬 |
For Alpine: I've (finally) submitted the newest Dlib into community. Let's hope that it gets through 🤞 |
Sorry, I didn't notice the version at first, I guess it's not of much use then |
I'm not really sure where else to ask and didn't want to create a new issue. For the past few days I've been messing around with docker trying to configure a build that works with Linuxserver's builds of nextcloud as well, for whatever reason I can't get reverse proxy to work with Nextcloud's official docker images. I was able to cobble something together after looking at work from @agboom that compiles correctly, but for whatever reason when running and I try to install the Face Recognition app from the NC app store it says that pdlib isn't installed--even though it actually is. Please help save my sanity, I just want to be able to show someone all the photos they're in from my photo library 🤣 I have a feeling I"m very close and just missing something (I'm a novice). WARNING: super crappy/ugly dockerfile but it works and all the tests pass. The multi staging is because the Linuxserver images can't use
edit: forgot to mention I'm running docker on unraid--unraid PHP is version 7.3.14 (cli) And the container PHP version is listed here showing pdlib. |
Hey guys, I've build a docker image and published it on docker hub. I will maintain this image. Everything is build on top of the official nextcloud apache image. Feel free to use it: https://hub.docker.com/r/iamklaus/nextcloud |
Thank you very much! Could you also port the latest nextcloud-fpm-alpine image? |
@ACarolan Did you ever manage to get it working for you? I'm currently in the same situation |
I did, I used @iamklaus 's docker image posted above with a couple tweaks. There were one or two things for my setup that didn't work so I abandoned it after also realizing it wouldn't be able to do what I wanted it to do. |
if anyone is still interested, here is a currently working setup for alpine fpm and nextcloud 24
|
I am also under an alpine image, so I can't use Face Recognition :( |
Know how to get this to work with 25? |
Hi everyone, We are going to try to use PECL, and maybe it will be interesting for all of you. |
For anyone using docker images based on alpine from linuxserver (https://hub.docker.com/r/linuxserver/nextcloud) I made it working using this compose file:
And this Dockerfile:
Using custom init scripts inside custom-cont-init.d directory as described here to build dlib and pdlib doesn't work, cmake returns a strange error which I haven't investigate. Has something to do with characters escape. But extending the main linuxserver Dockerfile and building the image myself, solved the problem. Also remember to add
to config/php/php-local.ini |
For proxmox Alpine Nextcloud Hub version 27, modified @blastbeng solution is working:
*note php82-dev and libjpeg-turbo-dev needed for below builds: Follow build instructions from https://github.com/goodspb/pdlib #Dlib #Pdlib |
Background
This is a continuation of the discussion in #214, where one of the goals was to install Facerecognition using precompiled binaries in Alpine Linux.
Alpine Linux is a small and simple Linux distribution, which makes it suitable for Docker based applications, due to its small footprint. Nextcloud provides Docker images based on Alpine Linux, with the tags suffixed with
-alpine
.Previous work has been done in #160 to compile the binaries manually using a Dockerfile.
Purpose
apk
).Current situation
We have packages for both
dlib
andphp7-pdlib
in the testing repository of Alpine, merged with these PRs:While the projects compile and the compiled binaries are present, loading the PDLib binaries cause a runtime error:
What needs to be done
Test setup/how to reproduce
I've created a Dockerfile to test the package.
Where
repositories
is:Building and running this with:
docker build --no-cache -f Dockerfile -t nextcloud-facerecognition:17-fpm-alpine . docker run nextcloud-facerecognition:latest
Yields the above runtime error.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: