Skip to content

Commit

Permalink
Merge branch 'docker'
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Jun 19, 2024
2 parents f047b30 + b00e2cd commit 738078a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 6 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ name: Continuous Integration
on:
push:
paths-ignore:
- .github/workflows/docker.yml
- .github/workflows/doxygen.yml
- 'doc/**'
- 'docker/**'
- '**.md'
pull_request:
schedule:
Expand All @@ -27,6 +30,10 @@ jobs:
build:
name: build (${{matrix.os}}, ${{matrix.robotology.yarp}}, ${{matrix.compiler.cc}})
runs-on: ${{matrix.os}}
container:
image: ghcr.io/roboticslab-uc3m/vision:${{matrix.os}}-opencv-4.x
env:
DEBIAN_FRONTEND: noninteractive
needs: maybe_skip
if: ${{needs.maybe_skip.outputs.should_skip != 'true'}}

Expand Down Expand Up @@ -63,8 +70,8 @@ jobs:
ref: ${{matrix.robotology.yarp}}
path: .deps/yarp

- name: Install dependencies via apt
run: sudo apt-get update && sudo apt-get install -qq ccache libopencv-dev libpcl-dev swig googletest
# - name: Install dependencies via apt
# run: apt-get update && apt-get upgrade -qqy

- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2
Expand All @@ -91,13 +98,13 @@ jobs:
run: |
cmake -S .deps/ycm -B .deps/ycm/build
cmake --build .deps/ycm/build
sudo cmake --install .deps/ycm/build
cmake --install .deps/ycm/build
- name: Build YARP
run: |
cmake -S .deps/yarp -B .deps/yarp/build $CMAKE_CCACHE_LAUNCHER -DSKIP_ACE=ON -DYARP_DISABLE_VERSION_SOURCE=ON
cmake --build .deps/yarp/build
sudo cmake --install .deps/yarp/build
cmake --install .deps/yarp/build
- name: Configure vision
run: cmake -S . -B build $CMAKE_CCACHE_LAUNCHER -DCREATE_BINDINGS_PYTHON=ON -DENABLE_examples=ON
Expand All @@ -106,11 +113,11 @@ jobs:
run: cmake --build build

- name: Install vision
run: sudo cmake --install build && sudo ldconfig
run: cmake --install build && ldconfig

- name: Test vision
working-directory: build
run: ctest -V

- name: Uninstall vision
run: sudo cmake --build build --target uninstall
run: cmake --build build --target uninstall
54 changes: 54 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Docker

on:
push:
paths:
- 'docker/**'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{github.repository}}

jobs:
docker:
name: build (Ubuntu ${{matrix.ubuntu}}, OpenCV ${{matrix.opencv}})
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
id-token: write

strategy:
matrix:
ubuntu: ['20.04', '22.04']
opencv: ['4.x']

steps:
- name: Check out main project
uses: actions/checkout@v4

- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{env.REGISTRY}}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
context: docker
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:ubuntu-${{matrix.ubuntu}}-opencv-${{matrix.opencv}}
labels: ${{steps.meta.outputs.labels}}
build-args: |
OPENCV_TAG=${{matrix.opencv}}
UBUNTU_TAG=${{matrix.ubuntu}}
31 changes: 31 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG UBUNTU_TAG
FROM ubuntu:${UBUNTU_TAG}

ARG OPENCV_TAG

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
g++ \
clang \
cmake \
wget \
unzip \
ccache \
libpcl-dev \
swig \
googletest && \
wget -O opencv.zip https://github.com/opencv/opencv/archive/${OPENCV_TAG}.zip && \
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_TAG}.zip && \
unzip opencv.zip && \
unzip opencv_contrib.zip && \
cmake -S opencv-${OPENCV_TAG} -B opencv-${OPENCV_TAG}/build \
-DOPENCV_EXTRA_MODULES_PATH=opencv_contrib-${OPENCV_TAG}/modules \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DOPENCV_ENABLE_NONFREE=ON && \
cmake --build opencv-${OPENCV_TAG}/build && \
cmake --install opencv-${OPENCV_TAG}/build && \
rm -rf opencv.zip opencv_contrib.zip opencv-${OPENCV_TAG} opencv_contrib-${OPENCV_TAG} && \
apt-get clean

0 comments on commit 738078a

Please sign in to comment.