Skip to content

Commit

Permalink
Merge branch 'master' into multi-stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Sep 28, 2023
2 parents a461967 + b0eb101 commit 36f460c
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 64 deletions.
19 changes: 0 additions & 19 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
# Basic dependabot.yml file with minimum configuration for two package managers

version: 2
updates:
# Enable version updates for python
- package-ecosystem: "pip"
# Look for a `requirements` in the `root` directory
directory: "/"
# Check for updates once a week
schedule:
interval: "monthly"
# Labels on pull requests for version updates only
labels:
- "CI / tests"
pull-request-branch-name:
# Separate sections of the branch name with a hyphen for example, `dependabot-npm_and_yarn-next_js-acorn-6.4.1`
separator: "-"
# Allow up to 5 open pull requests for pip dependencies
open-pull-requests-limit: 5
reviewers:
- "borda"

# Enable version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install pkg
run: pip install "check-jsonschema>=0.10"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
pre-commit-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4

- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3.3.1
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Publish Docker Image
# https://www.docker.com/blog/first-docker-github-action-is-here
# https://github.com/docker/build-push-action
on: # Trigger the workflow on push or pull request, but only for the master branch
on: # Trigger the workflow on push or pull request, but only for the master branch
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
Expand All @@ -17,25 +17,32 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
opencv_version: ["4.8.0"]
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
uses: actions/checkout@v4
# https://github.com/docker/setup-buildx-action
# Set up Docker Buildx - to use cache-from and cache-to argument of buildx command
- uses: docker/setup-buildx-action@v2
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
if: github.ref == 'refs/heads/master'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v4
- uses: docker/build-push-action@v5
# 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 .github/workflows/label-conflicts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
triage-conflicts:
runs-on: ubuntu-latest
steps:
- uses: mschilde/auto-label-merge-conflicts@8c6faa8a252e35ba5e15703b3d747bf726cdb95c # Oct 25, 2021
- uses: mschilde/auto-label-merge-conflicts@8c6faa8a252e35ba5e15703b3d747bf726cdb95c # Oct 25, 2021
with:
CONFLICT_LABEL_NAME: "has conflicts"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 13 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
autoupdate_schedule: quarterly
# submodules: true

Expand All @@ -17,6 +17,11 @@ repos:
- id: check-added-large-files
- id: detect-private-key

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
Expand All @@ -25,6 +30,13 @@ repos:
- mdformat-gfm
- mdformat_frontmatter

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
# https://prettier.io/docs/en/options.html#print-width
args: ["--print-width=120"]

# TODO: find an alternative which supports multi-stage builds
# - repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
# rev: v0.1.0
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore all MD files:
**/*.md
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Docker: Python-OpenCV-FFmpeg(-CUDA)

Repository for clean Dockerfile containing [FFmpeg](https://www.ffmpeg.org/), [OpenCV4](https://opencv.org/) and [Python2/3](https://www.python.org/), based on [Ubuntu](https://www.ubuntu.com/) 20.04 LTS.
Repository for clean Dockerfile containing [FFmpeg](https://www.ffmpeg.org/), [OpenCV4](https://opencv.org/) and [Python2/3](https://www.python.org/), based on [Ubuntu](https://www.ubuntu.com/) 22.04 LTS.

## Tags

Expand All @@ -26,7 +26,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
18 changes: 10 additions & 8 deletions cpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
# ============== BASE IMAGE =====================
# ===============================================

FROM ubuntu:20.04 AS base
ARG UBUNTU_VERSION=22.04

FROM ubuntu:${UBUNTU_VERSION} AS base

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

Expand All @@ -21,18 +23,20 @@ RUN \
# add sources for older pythons
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 \
build-essential \
cmake \
ffmpeg \
libtbb2 \
$( [ "$UBUNTU_VERSION" = "20.04" ] && libtbb2 || libtbb12 ) \
gfortran \
apt-utils \
pkg-config \
qt5-default \
qtbase5-dev qt5-qmake \
libopenblas-base \
libgstreamer1.0 \
libavcodec58 \
Expand All @@ -49,11 +53,8 @@ RUN \
wget \
unzip \
&& \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && \

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

RUN \
# 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 && \
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
Expand Down Expand Up @@ -174,4 +175,5 @@ RUN \
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 36f460c

Please sign in to comment.