[add] librephotos
This commit is contained in:
parent
ebc53109d4
commit
a23428dec3
44 changed files with 2123 additions and 0 deletions
14
librephotos-docker/backend/Dockerfile
Normal file
14
librephotos-docker/backend/Dockerfile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
FROM reallibrephotos/librephotos-dependencies:dev
|
||||
# actual project
|
||||
ARG DEBUG
|
||||
WORKDIR /code
|
||||
RUN git clone --depth 1 https://github.com/LibrePhotos/librephotos .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN if [ "$DEBUG" = 1 ] ; then \
|
||||
pip install setuptools==57.5.0; \
|
||||
pip install -r requirements.dev.txt; \
|
||||
fi
|
||||
EXPOSE 8001
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
CMD ["/entrypoint.sh"]
|
||||
93
librephotos-docker/backend/base/Dockerfile
Normal file
93
librephotos-docker/backend/base/Dockerfile
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
FROM ubuntu:jammy
|
||||
ARG TARGETPLATFORM
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# 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 \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# system packages installation
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
bzip2 \
|
||||
curl \
|
||||
ffmpeg \
|
||||
git \
|
||||
libboost-all-dev \
|
||||
libcfitsio-dev \
|
||||
libexif-dev \
|
||||
libexpat-dev \
|
||||
libexpat1-dev \
|
||||
libgif-dev \
|
||||
libgl1-mesa-glx \
|
||||
libglib2.0-dev \
|
||||
libgsf-1-dev \
|
||||
libheif-dev \
|
||||
libimage-exiftool-perl \
|
||||
libimagequant-dev \
|
||||
libjpeg-dev \
|
||||
liblapack-dev \
|
||||
liblcms2-dev \
|
||||
libmagic1 \
|
||||
libopenblas-dev \
|
||||
libopenexr-dev \
|
||||
liborc-dev \
|
||||
libpng-dev \
|
||||
libpq-dev \
|
||||
libraw-dev \
|
||||
librsvg2-dev \
|
||||
libsm6 \
|
||||
libtiff5-dev \
|
||||
libtool \
|
||||
libtool-bin \
|
||||
libwebp-dev \
|
||||
libxrender-dev \
|
||||
pkg-config \
|
||||
rustc \
|
||||
libtinfo5 \
|
||||
swig \
|
||||
unzip && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then pip3 install --no-cache-dir torch torchvision -f https://torch.kmtea.eu/whl/stable.html; else pip3 install --no-cache-dir torch torchvision; fi
|
||||
|
||||
RUN pip3 install --no-cache-dir cmake==3.21.2
|
||||
|
||||
#Build and install libraw
|
||||
WORKDIR /tmp/builds
|
||||
RUN git clone https://github.com/LibRaw/LibRaw && \
|
||||
cd LibRaw && \
|
||||
git reset --hard 2a9a4de21ea7f5d15314da8ee5f27feebf239655 && \
|
||||
autoreconf --install && \
|
||||
./configure && \
|
||||
make && \
|
||||
make install && \
|
||||
rm -rf /tmp/builds/*
|
||||
|
||||
#Build and install imagemagick
|
||||
WORKDIR /tmp/builds
|
||||
ARG IMAGEMAGICK_VERSION=7.1.0-48
|
||||
RUN curl -SL https://imagemagick.org/archive/releases/ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz | tar -xJf- && \
|
||||
cd ImageMagick-${IMAGEMAGICK_VERSION} && \
|
||||
./configure --with-modules && \
|
||||
make install && \
|
||||
ldconfig /usr/local/lib && \
|
||||
rm -rf /tmp/builds/*
|
||||
|
||||
# Build and install libvips
|
||||
WORKDIR /tmp/builds
|
||||
ARG VIPSVERSION=8.13.0
|
||||
RUN curl -SL https://github.com/libvips/libvips/releases/download/v${VIPSVERSION}/vips-${VIPSVERSION}.tar.gz | tar -xz \
|
||||
&& cd vips-${VIPSVERSION} \
|
||||
&& ./configure \
|
||||
&& make V=0 \
|
||||
&& make install \
|
||||
&& ldconfig \
|
||||
&& rm -rf /tmp/builds/*
|
||||
21
librephotos-docker/backend/dependencies/Dockerfile
Normal file
21
librephotos-docker/backend/dependencies/Dockerfile
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
FROM reallibrephotos/librephotos-base:dev
|
||||
|
||||
# Build and install dlib
|
||||
# Compile it WITHOUT AVX and SSE4 instructions to ensure compatibility
|
||||
WORKDIR /tmp/builds
|
||||
RUN git clone --depth 1 --branch 'v19.24' https://github.com/davisking/dlib.git && \
|
||||
mkdir dlib/build && \
|
||||
cd dlib/build && \
|
||||
cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=0 -DLIB_NO_GUI_SUPPORT=0 && \
|
||||
cmake --build . && \
|
||||
cd /tmp/builds/dlib && \
|
||||
python3 setup.py install --no USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA --no USE_SSE4_INSTRUCTIONS && \
|
||||
rm -rf /tmp/builds/*
|
||||
|
||||
# Download pretrained models
|
||||
WORKDIR /data_models
|
||||
RUN mkdir -p /root/.cache/torch/hub/checkpoints/ && \
|
||||
curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/places365.tar.gz | tar -zxC /data_models/ && \
|
||||
curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/im2txt.tar.gz | tar -zxC /data_models/ && \
|
||||
curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/clip-embeddings.tar.gz | tar -zxC /data_models/ && \
|
||||
curl -SL https://download.pytorch.org/models/resnet152-b121ed2d.pth -o /root/.cache/torch/hub/checkpoints/resnet152-b121ed2d.pth
|
||||
27
librephotos-docker/backend/entrypoint.sh
Normal file
27
librephotos-docker/backend/entrypoint.sh
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#! /bin/bash
|
||||
export PYTHONUNBUFFERED=TRUE
|
||||
export PYTHONFAULTHANDLER=1
|
||||
mkdir -p /logs
|
||||
python image_similarity/main.py 2>&1 | tee /logs/gunicorn_image_similarity.log &
|
||||
python manage.py showmigrations | tee /logs/show_migrate.log
|
||||
python manage.py migrate | tee /logs/command_migrate.log
|
||||
python manage.py showmigrations | tee /logs/show_migrate.log
|
||||
python manage.py clear_cache
|
||||
|
||||
if [ -n "$ADMIN_USERNAME" ]
|
||||
then
|
||||
python manage.py createadmin -u $ADMIN_USERNAME $ADMIN_EMAIL 2>&1 | tee /logs/command_createadmin.log
|
||||
fi
|
||||
|
||||
echo "Running backend server..."
|
||||
|
||||
python manage.py rqworker default 2>&1 | tee /logs/rqworker.log &
|
||||
|
||||
if [ "$DEBUG" = 1 ]
|
||||
then
|
||||
echo "development backend starting"
|
||||
gunicorn --worker-class=gevent --reload --bind 0.0.0.0:8001 --log-level=info ownphotos.wsgi 2>&1 | tee /logs/gunicorn_django.log
|
||||
else
|
||||
echo "production backend starting"
|
||||
gunicorn --worker-class=gevent --bind 0.0.0.0:8001 --log-level=info ownphotos.wsgi 2>&1 | tee /logs/gunicorn_django.log
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue