mirror of
https://github.com/Hellowlol/bw_plex.git
synced 2025-12-20 08:29:31 -06:00
Shrink the docker image via multi-stage builds
This restructures the entire docker image build process to first install bw_plex and its python dependencies into a virtualenv in a "builder" docker container; then the main image build merely installs the runtime dependencies and copies the virtualenv contents over, setting the appropriate $PATH variable. Additionally, use the contents of the current git checkout to build the docker image, as opposed to downloading the source code from github & pip-installing that. In addition to saving space, should allow developers to test their changes better.
This commit is contained in:
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
__pycache__
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
.Python
|
||||||
|
*.whl
|
||||||
|
Dockerfile
|
||||||
44
Dockerfile
44
Dockerfile
@@ -1,8 +1,24 @@
|
|||||||
|
FROM ubuntu:18.04 AS builder
|
||||||
|
ENV DEBIAN_FRONTEND="noninteractive"
|
||||||
|
ENV LC_ALL C.UTF-8
|
||||||
|
ENV lang C.UTF-8
|
||||||
|
RUN apt-get update && apt-get -y install \
|
||||||
|
git-core swig libpulse-dev libasound2-dev ffmpeg tesseract-ocr python3-pip pandoc python3.6-tk \
|
||||||
|
python3-setuptools python3-venv && apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* && \
|
||||||
|
python3 -m venv /app/bw_plex
|
||||||
|
|
||||||
|
ENV PATH="/app/bw_plex/bin:$PATH"
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Python requirements from pip
|
||||||
|
RUN pip3 --no-cache-dir install pytest pytest-cov pytest-mock pytest_click pypandoc codecov \
|
||||||
|
opencv-contrib-python-headless SpeechRecognition pocketsphinx pytesseract
|
||||||
|
|
||||||
|
ADD . /src
|
||||||
|
RUN pip3 --no-cache-dir wheel -e . && pip3 --no-cache-dir install bw_plex*.whl
|
||||||
|
|
||||||
FROM ubuntu:18.04
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
# This images is much bigger then i want, ill try to reduce it
|
|
||||||
# but im such a docker noob, send a PR if you know how to fix it.
|
|
||||||
|
|
||||||
LABEL maintainer="hellowlol1@gmail.com"
|
LABEL maintainer="hellowlol1@gmail.com"
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND="noninteractive"
|
ENV DEBIAN_FRONTEND="noninteractive"
|
||||||
@@ -11,22 +27,12 @@ ENV lang C.UTF-8
|
|||||||
|
|
||||||
# Package requirements
|
# Package requirements
|
||||||
RUN apt-get update && apt-get -y install \
|
RUN apt-get update && apt-get -y install \
|
||||||
git swig libpulse-dev libasound2-dev ffmpeg tesseract-ocr python3-pip pandoc python3.6-tk \
|
libpulse0 libasound2 ffmpeg tesseract-ocr python3-pip pandoc python3.6-tk \
|
||||||
python3-setuptools && apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/* && \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
mkdir -p /app/bw_plex
|
|
||||||
|
|
||||||
# Python requirements from pip
|
COPY --from=builder /app/bw_plex /app/bw_plex
|
||||||
RUN pip3 install pytest pytest-cov pytest-mock pytest_click pypandoc codecov \
|
ENV PATH="/app/bw_plex/bin:$PATH"
|
||||||
opencv-contrib-python-headless SpeechRecognition pocketsphinx pytesseract
|
|
||||||
|
|
||||||
RUN git clone --depth=1 https://github.com/Hellowlol/bw_plex.git /app/bw_plex
|
|
||||||
#&& rm -rf /app/bw_plex/.git
|
|
||||||
|
|
||||||
# This is needed for the the manual install of bw_plex
|
|
||||||
WORKDIR /app/bw_plex
|
|
||||||
|
|
||||||
RUN pip3 install -e .
|
|
||||||
|
|
||||||
# COPY root/ /
|
# COPY root/ /
|
||||||
VOLUME /config
|
VOLUME /config
|
||||||
|
|||||||
Reference in New Issue
Block a user