Skip to content

Commit

Permalink
bump base OS to ubuntu:22.04 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Sep 28, 2023
1 parent aaef6e4 commit 2e76719
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 44 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
ubuntu_version: ["20.04"]
python_version: ["2.7", "3.6", "3.7", "3.8", "3.9"]
opencv_version: ["4.8.1"]
device: ["cpu", "gpu"]
include:
- {ubuntu_version: "22.04", python_version: "3.10", opencv_version: "4.8.1", device: "cpu"}
- {ubuntu_version: "22.04", python_version: "3.10", opencv_version: "4.8.1", device: "gpu"}
- {ubuntu_version: "22.04", python_version: "3.11", opencv_version: "4.8.1", device: "cpu"}
- {ubuntu_version: "22.04", python_version: "3.11", opencv_version: "4.8.1", device: "gpu"}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -36,6 +42,7 @@ jobs:
# https://github.com/docker/build-push-action#cache-to-registry
with:
build-args: |
UBUNTU_VERSION=${{ matrix.ubuntu_version }}
PYTHON_VERSION=${{ matrix.python_version }}
OPENCV_VERSION=${{ matrix.opencv_version }}
file: ${{ matrix.device }}/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You can build it on your own, note it takes lots of time, be prepared.
```bash
git clone <git-repository>
cd docker_python-opencv-ffmpeg
docker image build -t python-opencv-ffmpeg:py3.8 -f gpu/Dockerfile --build-arg PYTHON_VERSION=3.8 .
docker image build -t python-opencv-ffmpeg:py3.9 -f cpu/Dockerfile --build-arg PYTHON_VERSION=3.9 .
```

To build other versions, select different Dockerfile.
Expand Down
40 changes: 19 additions & 21 deletions cpu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# https://www.learnopencv.com/install-opencv3-on-ubuntu/
# https://www.osradar.com/how-to-install-opencv-on-ubuntu-20-04/

FROM ubuntu:20.04
ARG UBUNTU_VERSION=22.04

FROM ubuntu:${UBUNTU_VERSION}

LABEL maintainer="https://github.com/Borda"

Expand All @@ -11,14 +13,17 @@ ARG OPENCV_VERSION=4.8.0
# Needed for string substitution
SHELL ["/bin/bash", "-c"]
# https://techoverflow.net/2019/05/18/how-to-fix-configuring-tzdata-interactive-input-when-building-docker-images/
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Prague
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Europe/Prague


RUN \
# add sources for older pythons
apt-get update --fix-missing && \
apt-get update -q --fix-missing && \
apt-get install -y --no-install-recommends software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
if [[ "$PYTHON_VERSION" =~ ^(2.7|3.6|3.7)$ ]]; then \
add-apt-repository ppa:deadsnakes/ppa ; \
fi && \
apt-add-repository universe && \
apt-get -y update -qq --fix-missing && \
apt-get -y install --no-install-recommends \
Expand All @@ -28,6 +33,7 @@ RUN \
curl \
wget \
&& \
rm -rf /var/lib/apt/lists/* && \

# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
Expand All @@ -41,8 +47,7 @@ RUN \
apt-get -y install --no-install-recommends python${PYTHON_VERSION}-distutils ; \
PIP_URL="https://bootstrap.pypa.io/get-pip.py" ; \
fi && \
curl $PIP_URL | python && \
rm -rf /var/lib/apt/lists/*
curl $PIP_URL | python

ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages:/usr/local/lib/python${PYTHON_VERSION}/site-packages"

Expand All @@ -53,30 +58,24 @@ RUN \
unzip \
cmake \
ffmpeg \
libtbb2 \
$( [ "$UBUNTU_VERSION" = "20.04" ] && libtbb2 || libtbb12 ) \
gfortran \
apt-utils \
pkg-config \
checkinstall \
qt5-default \
qtbase5-dev qt5-qmake \
build-essential \
libopenblas-base \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
#libgtk-3-dev \
#libavcodec58 \
libavcodec-dev \
#libavformat58 \
libavformat-dev \
libavutil-dev \
#libswscale5 \
libswscale-dev \
libjpeg8-dev \
libpng-dev \
libtiff5-dev \
#libdc1394-22 \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
libgstreamer1.0 \
Expand All @@ -92,7 +91,7 @@ RUN \
libxext6 \
libxrender1 \
&& \
pip${PYTHON_VERSION} install numpy && \
pip install numpy && \

# Install OpenCV
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -O opencv.zip --progress=bar:force:noscroll --no-check-certificate && \
Expand Down Expand Up @@ -152,31 +151,30 @@ RUN \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
#libgtk-3-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libjpeg8-dev \
libpng-dev \
libtiff5-dev \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libglew-dev \
libpostproc-dev \
libeigen3-dev \
libtbb-dev \
zlib1g-dev \
&& \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/* && \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/*

# Call default command.
RUN \
# Call default command.
ffmpeg -version && \
#ldd `which ffmpeg` && \
python --version && \
pip list && \
python -c "import cv2 ; print(cv2.__version__)"
38 changes: 17 additions & 21 deletions gpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

# CALL: docker image build -t python-opencv-ffmpeg:py36 -f cpu/Dockerfile --build-arg PYTHON_VERSION=3.6 .

ARG CUDA_VERSION=11.7.1
ARG CUDA_VERSION=11.8.0
ARG UBUNTU_VERSION=22.04

FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu20.04
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}

LABEL maintainer="https://github.com/Borda"

Expand All @@ -17,16 +18,18 @@ ARG OPENCV_VERSION=4.8.0
# Needed for string substitution
SHELL ["/bin/bash", "-c"]
# https://techoverflow.net/2019/05/18/how-to-fix-configuring-tzdata-interactive-input-when-building-docker-images/
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Prague
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Europe/Prague

# ENV LD_LIBRARY_PATH /usr/local/${CUDA}/compat:$LD_LIBRARY_PATH

RUN \
# add sources for older pythons
apt-get update -qq --fix-missing && \
apt-get install -y --no-install-recommends software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
if [[ "$PYTHON_VERSION" =~ ^(2.7|3.6|3.7)$ ]]; then \
add-apt-repository ppa:deadsnakes/ppa ; \
fi && \
apt-add-repository universe && \
apt-get -y update -qq --fix-missing && \
apt-get -y install --no-install-recommends \
Expand All @@ -36,6 +39,7 @@ RUN \
curl \
wget \
&& \
rm -rf /var/lib/apt/lists/* && \

# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
Expand All @@ -49,8 +53,7 @@ RUN \
apt-get -y install --no-install-recommends python${PYTHON_VERSION}-distutils ; \
PIP_URL="https://bootstrap.pypa.io/get-pip.py" ; \
fi && \
curl $PIP_URL | python && \
rm -rf /var/lib/apt/lists/*
curl $PIP_URL | python

ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages:/usr/local/lib/python${PYTHON_VERSION}/site-packages"

Expand All @@ -67,30 +70,24 @@ RUN \
unzip \
cmake \
ffmpeg \
libtbb2 \
$( [ "$UBUNTU_VERSION" = "20.04" ] && libtbb2 || libtbb12 ) \
gfortran \
apt-utils \
pkg-config \
checkinstall \
qt5-default \
qtbase5-dev qt5-qmake \
build-essential \
libopenblas-base \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
#libgtk-3-dev \
#libavcodec58 \
libavcodec-dev \
#libavformat58 \
libavformat-dev \
libavutil-dev \
#libswscale5 \
libswscale-dev \
libjpeg8-dev \
libpng-dev \
libtiff5-dev \
#libdc1394-22 \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
libgstreamer1.0 \
Expand All @@ -106,7 +103,7 @@ RUN \
libxext6 \
libxrender1 \
&& \
pip${PYTHON_VERSION} install numpy && \
pip install numpy && \

# Install OpenCV
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip -O opencv.zip --progress=bar:force:noscroll && \
Expand Down Expand Up @@ -177,31 +174,30 @@ RUN \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
#libgtk-3-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libjpeg8-dev \
libpng-dev \
libtiff5-dev \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libglew-dev \
libpostproc-dev \
libeigen3-dev \
libtbb-dev \
zlib1g-dev \
&& \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/* && \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/*

# Call default command.
RUN \
# Call default command.
ffmpeg -version && \
#ldd `which ffmpeg` && \
python --version && \
pip list && \
python -c "import cv2 ; print(cv2.__version__)"

0 comments on commit 2e76719

Please sign in to comment.