From 17c73a4af4f5df8ff66f378d1143321fa4edd681 Mon Sep 17 00:00:00 2001
From: Niaz Faridani-Rad <faridani.rad@gmail.com>
Date: Wed, 14 Jul 2021 00:51:11 +0200
Subject: [PATCH] [FIX] Dependencies

---
 backend/Dockerfile | 71 +++++++++++++++++++++++++++++++++++++++++-----
 docker-compose.yml |  2 +-
 2 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/backend/Dockerfile b/backend/Dockerfile
index 86a1c5d..4af4e02 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -1,17 +1,74 @@
-FROM python:3.8-slim-buster
-
+FROM ubuntu:groovy
 # system packages installation
 
-RUN apt update && apt install -y libvips ffmpeg libimage-exiftool-perl curl nfs-common cifs-utils libopenblas-dev libmagickwand-dev libheif-dev libmagic1 ufraw-batch libboost-all-dev libxrender-dev liblapack-dev git bzip2 cmake build-essential libsm6 libglib2.0-0 libgl1-mesa-glx libpq-dev --no-install-recommends
+RUN apt update && apt install -y ffmpeg libimage-exiftool-perl curl nfs-common cifs-utils libopenblas-dev libheif-dev libmagic1 libraw-dev libboost-all-dev libxrender-dev liblapack-dev git bzip2 cmake build-essential libsm6 libglib2.0-dev libgl1-mesa-glx libpq-dev libexpat-dev \
+	librsvg2-dev \
+	libpng-dev \
+	libgif-dev \
+	libjpeg-dev \
+	libexif-dev \
+	liblcms2-dev \
+	liborc-dev \
+	pkg-config \ 
+	libexpat1-dev \ 
+	libtiff5-dev \ 
+	libgsf-1-dev \ 
+	libopenexr-dev \ 
+	libcfitsio-dev \ 
+	libimagequant-dev \
+	libtool \ 
+	libtool-bin \
+	wget \
+	libwebp-dev --no-install-recommends
+#Build and install python
+RUN apt-get update \
+  && apt-get install -y python3-pip python3-dev \
+  && cd /usr/local/bin \
+  && ln -s /usr/bin/python3 python \
+  && pip3 install --upgrade pip
+
+#Build and install libraw
+#RUN mkdir /libraw
+#RUN curl -SL https://www.libraw.org/data/LibRaw-0.20.2.tar.gz | tar -zxC /libraw
+RUN git clone https://github.com/LibRaw/LibRaw
+RUN ls
+WORKDIR /LibRaw
+RUN autoreconf --install
+RUN ./configure
+RUN make
+RUN make install
+
+#Build and install imagemagick
+WORKDIR /
+RUN mkdir /imagemagick
+RUN curl -SL https://www.imagemagick.org/download/ImageMagick.tar.gz | tar -zxC /imagemagick
+WORKDIR /imagemagick/ImageMagick-7.1.0-2
+RUN ./configure --with-modules
+RUN make install
+RUN ldconfig /usr/local/lib
+
+# Build and install libvips
+ARG VIPSVERSION=8.11.0
+ARG VIPSURL=https://github.com/libvips/libvips/releases/download
+WORKDIR /usr/local/src
+RUN wget ${VIPSURL}/v${VIPSVERSION}/vips-${VIPSVERSION}.tar.gz \ 
+	&& tar xzf vips-${VIPSVERSION}.tar.gz \ 
+	&& cd vips-${VIPSVERSION} \ 
+	&& ./configure \ 
+	&& make V=0 \ 
+	&& make install \ 
+	&& ldconfig
 
 # pre trained models download
 WORKDIR /data_models
 RUN mkdir -p /root/.cache/torch/hub/checkpoints/
-RUN curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/places365.tar.gz | tar -zxC /data_models/
-RUN curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/im2txt.tar.gz | tar -zxC /data_models/
-RUN curl -SL https://download.pytorch.org/models/resnet152-b121ed2d.pth -o /root/.cache/torch/hub/checkpoints/resnet152-b121ed2d.pth
+RUN curl -SL -k https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/places365.tar.gz | tar -zxC /data_models/
+RUN curl -SL -k https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/im2txt.tar.gz | tar -zxC /data_models/
+RUN curl -SL -k https://download.pytorch.org/models/resnet152-b121ed2d.pth -o /root/.cache/torch/hub/checkpoints/resnet152-b121ed2d.pth
 RUN pip install torch==1.8.0+cpu torchvision==0.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
 
+RUN pip3 install pyvips
+
 # Build and install dlib
 WORKDIR /
 RUN git clone https://github.com/davisking/dlib.git && \
@@ -25,7 +82,7 @@ RUN git clone https://github.com/davisking/dlib.git && \
 # actual project
 ARG DEBUG
 WORKDIR /code
-RUN git clone https://github.com/LibrePhotos/librephotos .
+COPY . .
 RUN pip install -r requirements.txt
 RUN if [ "$DEBUG" = 1 ] ; then pip install -r requirements.dev.txt ;  fi
 RUN python -m spacy download en_core_web_sm
diff --git a/docker-compose.yml b/docker-compose.yml
index 6b1a2e0..8721e75 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -39,7 +39,7 @@ services:
       - backend
 
   backend:
-    image: reallibrephotos/librephotos:${tag}
+    image: reallibrephotos/librephotos-backend:${tag}
     restart: always
     volumes:
       - ${myPhotos}:/data
-- 
GitLab