未验证 提交 61adec55 编写于 作者: R Roman Donchenko 提交者: GitHub

Make mild improvements to the main Dockerfile (#5994)

This applies several minor improvements that together shave off a little
bit of build time (on my machine, it goes down from 14:10 to 13:20) and
a little bit of size of the final image (likely just a few megabytes, so
I didn't measure it exactly).
上级 10fb2b41
ARG PIP_VERSION=22.0.2
FROM ubuntu:20.04 as build-image
ARG http_proxy
ARG https_proxy
ARG no_proxy="nuclio,${no_proxy}"
ARG socks_proxy
ARG DJANGO_CONFIGURATION="production"
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install -yq \
apache2-dev \
build-essential \
curl \
libgeos-dev \
g++ \
gcc \
git \
libldap2-dev \
libsasl2-dev \
make \
nasm \
git \
pkg-config \
python3-dev \
python3-pip \
python3-venv && \
rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*
# Compile Openh264 and FFmpeg
ARG PREFIX=/opt/ffmpeg
......@@ -32,29 +30,30 @@ ENV FFMPEG_VERSION=4.3.1 \
WORKDIR /tmp/openh264
RUN curl -sL https://github.com/cisco/openh264/archive/v${OPENH264_VERSION}.tar.gz --output openh264-${OPENH264_VERSION}.tar.gz && \
tar -zx --strip-components=1 -f openh264-${OPENH264_VERSION}.tar.gz && \
make -j5 && make install PREFIX=${PREFIX} && make clean
make -j5 && make install-shared PREFIX=${PREFIX} && make clean
WORKDIR /tmp/ffmpeg
RUN curl -sL https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 --output - | \
tar -jx --strip-components=1 && \
./configure --disable-nonfree --disable-gpl --enable-libopenh264 --enable-shared --disable-static --prefix="${PREFIX}" && \
./configure --disable-nonfree --disable-gpl --enable-libopenh264 \
--enable-shared --disable-static --disable-doc --disable-programs --prefix="${PREFIX}" && \
# make clean keeps the configuration files that let to know how the original sources were used to create the binary
make -j5 && make install && make clean && \
tar -zcf "/tmp/ffmpeg-$FFMPEG_VERSION.tar.gz" . && mv "/tmp/ffmpeg-$FFMPEG_VERSION.tar.gz" .
# Install requirements
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
RUN python3 -m pip install --no-cache-dir -U pip==22.0.2 setuptools==60.6.0 wheel==0.37.1
# Build wheels for all dependencies
ARG PIP_VERSION
RUN python3 -m pip install -U pip==${PIP_VERSION}
COPY cvat/requirements/ /tmp/requirements/
COPY utils/dataset_manifest/ /tmp/dataset_manifest/
# The server implementation depends on the dataset_manifest utility
# so we need to install its dependencies too
# so we need to build its dependencies too
# https://github.com/opencv/cvat/issues/5096
RUN DATUMARO_HEADLESS=1 python3 -m pip install --no-cache-dir \
RUN DATUMARO_HEADLESS=1 python3 -m pip wheel --no-cache-dir \
-r /tmp/requirements/${DJANGO_CONFIGURATION}.txt \
-r /tmp/dataset_manifest/requirements.txt
-r /tmp/dataset_manifest/requirements.txt \
-w /tmp/wheelhouse
FROM ubuntu:20.04
......@@ -82,23 +81,24 @@ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install -yq \
apache2 \
ca-certificates \
curl \
git \
git-lfs \
libapache2-mod-xsendfile \
libgeos-dev \
libgomp1 \
libgl1 \
supervisor \
libgomp1 \
libldap-2.4-2 \
libpython3.8 \
libsasl2-2 \
libpython3-dev \
tzdata \
python3-distutils \
p7zip-full \
git \
git-lfs \
poppler-utils \
python3 \
python3-distutils \
python3-venv \
ssh \
curl && \
ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
supervisor \
tzdata \
&& ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
rm -rf /var/lib/apt/lists/* && \
echo 'application/wasm wasm' >> /etc/mime.types
......@@ -142,11 +142,16 @@ RUN if [ "$INSTALL_SOURCES" = "yes" ]; then \
fi
COPY --from=build-image /tmp/openh264/openh264*.tar.gz /tmp/ffmpeg/ffmpeg*.tar.gz ${HOME}/sources/
# Copy python virtual environment and FFmpeg binaries from build-image
COPY --from=build-image /opt/venv /opt/venv
# Install wheels from the build image
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
ARG PIP_VERSION
RUN python -m pip install -U pip==${PIP_VERSION}
RUN --mount=type=bind,from=build-image,source=/tmp/wheelhouse,target=/mnt/wheelhouse \
python -m pip install --no-index /mnt/wheelhouse/*.whl
ENV NUMPROCS=1
COPY --from=build-image /opt/ffmpeg /usr
COPY --from=build-image /opt/ffmpeg/lib /usr/lib
# These variables are required for supervisord substitutions in files
# This library allows remote python debugging with VS Code
......
FROM node:lts-slim AS cvat-ui
ARG http_proxy
ARG https_proxy
ARG no_proxy
ARG socks_proxy
ARG WA_PAGE_VIEW_HIT
ARG UI_APP_CONFIG
ARG CLIENT_PLUGINS
ENV TERM=xterm \
http_proxy=${http_proxy} \
https_proxy=${https_proxy} \
no_proxy=${no_proxy} \
socks_proxy=${socks_proxy} \
LANG='C.UTF-8' \
LC_ALL='C.UTF-8'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册