Skip to content
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

Add docker multi stage build #17

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM python:3.8-slim-buster
FROM python:3.8-slim-buster as base

# system packages installation

RUN apt update && apt install -y 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

FROM base as model
# pre trained models download
WORKDIR /data_models
RUN mkdir -p /root/.cache/torch/hub/checkpoints/
Expand All @@ -12,6 +13,7 @@ RUN curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download
RUN curl -SL 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

FROM base as dlib
# Build and install dlib
WORKDIR /
RUN git clone https://github.com/davisking/dlib.git && \
Expand All @@ -23,6 +25,7 @@ RUN git clone https://github.com/davisking/dlib.git && \
python setup.py install --no USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA --no USE_SSE4_INSTRUCTIONS

# actual project
FROM base
ARG DEBUG
WORKDIR /code
RUN git clone https://github.com/LibrePhotos/librephotos .
Expand All @@ -31,5 +34,8 @@ RUN if [ "$DEBUG" = 1 ] ; then pip install -r requirements.dev.txt ; fi
RUN python -m spacy download en_core_web_sm
EXPOSE 8001

COPY --from=model /data_models /data-models
COPY --from=dlib /dlib/build /dlib/build
COPY entrypoint.sh /entrypoint.sh
CMD ["/entrypoint.sh"]