Skip to content

Commit

Permalink
Put versions for all dependencies in dependency_versions and wrote re…
Browse files Browse the repository at this point in the history
…usable scripts for installing dependencies
  • Loading branch information
TimSchneider42 committed May 25, 2024
1 parent 73aa655 commit c3e66e7
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 98 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,29 @@ Make sure that the built library can be found from Python by adapting your Pytho

#### Using Docker

To use franky within Docker we provide a [Dockerfile](docker/run/Dockerfile).
To use franky within Docker we provide a [Dockerfile](docker/run/Dockerfile) and accompanying [docker-compose](docker-compose.yml) file.

```bash
git clone https://github.com/timschneider42/franky.git
cd franky/
docker build -t franky --build-arg LIBFRANKA_VERSION=0.13.3 -f docker/run/Dockerfile .
docker compose build franky-run
```

To use another version of libfranka than the default (v.0.13.3) simply change the build argument. Then, to run the container simply:

To use another version of libfranka than the default (v0.13.3) add a build argument:
```bash
docker run -it --rm --network=host --privileged franky /bin/bash
docker compose build franky-run --build-arg LIBFRANKA_VERSION=0.9.2
```

To run the container:
```bash
docker compose run franky-run bash
```
The container requires access to the host machines network *and* elevated user rights to allow the docker user to set RT capabilities of the processes run from within it.


#### Building franky with Docker

For building franky and its wheels, we provide a Docker container that can be launched using docker-compose:
For building franky and its wheels, we provide another Docker container that can also be launched using docker-compose:

```bash
docker compose build
Expand Down
4 changes: 4 additions & 0 deletions dependency_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EIGEN_VERSION=3.4.0
PYBIND11_VERSION=2.11.1
CATCH2_VERSION=2.13.8
LIBFRANKA_DEFAULT_VERSION=0.13.3
10 changes: 9 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
services:
franky-build:
build: ./docker/build
build:
context: .
dockerfile: ./docker/build/Dockerfile
volumes:
- ./:/code
- ./build:/build
franky-run:
build:
context: .
dockerfile: ./docker/run/Dockerfile
network_mode: "host"
privileged: true
61 changes: 11 additions & 50 deletions docker/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,23 @@ LABEL maintainer="Tim Schneider <[email protected]>"

RUN yum -y install poco-devel*

WORKDIR /tmp

RUN git clone https://gitlab.com/libeigen/eigen.git \
&& cd eigen \
&& git checkout 3.4.0 \
&& mkdir build && cd build \
&& cmake .. \
&& make install \
&& cd /tmp && rm -rf eigen

RUN git clone https://github.com/catchorg/Catch2.git \
&& cd Catch2 \
&& git checkout v2.13.8 \
&& mkdir build && cd build \
&& cmake -DCATCH_BUILD_TESTING=OFF -DCATCH_ENABLE_WERROR=OFF -DCATCH_INSTALL_DOCS=OFF -DCATCH_INSTALL_HELPERS=OFF .. \
&& make install \
&& cd /tmp && rm -rf Catch2

RUN git clone https://github.com/pybind/pybind11.git \
&& cd pybind11 \
&& git checkout v2.11.1 \
&& mkdir build && cd build \
&& cmake -DPYBIND11_TEST=OFF .. \
&& make -j$(nproc) \
&& make install \
&& cd /tmp && rm -rf pybind11
ADD dependency_versions /tmp/
ADD docker/common/ /tmp/common/
ARG LIBFRANKA_VERSION
RUN set -a && . /tmp/dependency_versions && set +a \
&& /tmp/common/install-dependencies

ARG PYBIN_SUPPORTED_VERSIONS="cp3(7m|8|9|10|11|12)"
ENV PYBIN_SUPPORTED_VERSIONS=${PYBIN_SUPPORTED_VERSIONS}
RUN for PYBIN in /opt/python/*/bin; do \
if [[ "${PYBIN}" =~ ${PYBIN_SUPPORTED_VERSIONS} ]]; then \
"${PYBIN}/pip" install cmake setuptools wheel --user; \
fi; \
done \
&& ln -f -s $HOME/.local/bin/cmake /usr/bin/cmake

ARG LIBFRANKA_VERSION=0.13.3
RUN git clone --recursive https://github.com/frankaemika/libfranka.git \
&& cd libfranka \
&& git checkout "${LIBFRANKA_VERSION}" \
# Cherry-pick missing imports commit
&& git config user.email "[email protected]" \
&& git config user.name "John Doe" \
&& if ! git merge-base --is-ancestor f1f46fb HEAD; then git cherry-pick -m 1 f1f46fb; fi \
&& git submodule update \
&& mkdir build && cd build \
&& cmake -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF .. \
&& make -j$(nproc) \
&& make install \
&& cd /tmp && rm -rf libfranka
RUN /tmp/common/manylinux-setup-pip

# Set working directory
RUN mkdir -p /code
RUN mkdir -p /build
VOLUME /code
VOLUME /build
WORKDIR /build
ADD build-wheels /usr/bin/
ADD run-tests /usr/bin/
ADD docker/build/build-wheels /usr/bin/
ADD docker/build/run-tests /usr/bin/

# Cleaning up
RUN rm -rf /tmp/common
15 changes: 15 additions & 0 deletions docker/common/install-catch2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

echo "Installing Catch2 version ${CATCH2_VERSION}..."
TMP_DIR="$(mktemp -d)"
git clone https://github.com/catchorg/Catch2.git "${TMP_DIR}"
cd "${TMP_DIR}"
git checkout "v${CATCH2_VERSION}"
mkdir build
cd build
cmake -DCATCH_BUILD_TESTING=OFF -DCATCH_ENABLE_WERROR=OFF -DCATCH_INSTALL_DOCS=OFF -DCATCH_INSTALL_HELPERS=OFF ..
make install
cd /
rm -rf "${TMP_DIR}"
echo "Catch2 installed successfully"
11 changes: 11 additions & 0 deletions docker/common/install-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

echo "Installing dependencies..."
"${SCRIPT_DIR}/install-eigen"
"${SCRIPT_DIR}/install-pybind11"
"${SCRIPT_DIR}/install-catch2"
"${SCRIPT_DIR}/install-libfranka"
echo "Dependencies installed successfully"
15 changes: 15 additions & 0 deletions docker/common/install-eigen
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

echo "Installing Eigen version ${EIGEN_VERSION}..."
TMP_DIR="$(mktemp -d)"
git clone https://gitlab.com/libeigen/eigen.git "${TMP_DIR}"
cd "${TMP_DIR}"
git checkout "${EIGEN_VERSION}"
mkdir build
cd build
cmake ..
make install
cd /
rm -rf "${TMP_DIR}"
echo "Eigen installed successfully"
26 changes: 26 additions & 0 deletions docker/common/install-libfranka
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e

LIBFRANKA_VERSION="${LIBFRANKA_VERSION:-${LIBFRANKA_DEFAULT_VERSION}}"
echo "Installing libfranka version ${LIBFRANKA_VERSION}..."
TMP_DIR="$(mktemp -d)"
git clone --recursive https://github.com/frankaemika/libfranka.git "${TMP_DIR}"
cd "${TMP_DIR}"

git checkout "${LIBFRANKA_VERSION}"

# Cherry-pick missing imports commit
git config user.email "[email protected]"
git config user.name "John Doe"
if ! git merge-base --is-ancestor f1f46fb HEAD; then git cherry-pick -m 1 f1f46fb; fi
git submodule update

mkdir build
cd build
cmake -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF ..
make -j "$(nproc)"
make install

cd /
rm -rf "${TMP_DIR}"
echo "libfranka installed successfully"
16 changes: 16 additions & 0 deletions docker/common/install-pybind11
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

echo "Installing pybind11 version ${PYBIND11_VERSION}..."
TMP_DIR="$(mktemp -d)"
git clone https://github.com/pybind/pybind11.git "${TMP_DIR}"
cd "${TMP_DIR}"
git checkout "v${PYBIND11_VERSION}"
mkdir build
cd build
cmake -DPYBIND11_TEST=OFF ..
make -j "$(nproc)"
make install
cd /
rm -rf "${TMP_DIR}"
echo "pybind11 installed successfully"
10 changes: 10 additions & 0 deletions docker/common/manylinux-setup-pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

echo "Setting up pip..."
for PYBIN in /opt/python/*/bin; do
if [[ "${PYBIN}" =~ ${PYBIN_SUPPORTED_VERSIONS} ]]; then
"${PYBIN}/pip" install setuptools wheel --user
fi
done
echo "pip set up successfully"
49 changes: 8 additions & 41 deletions docker/run/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,11 @@ LABEL maintainer="Tim Schneider <[email protected]>"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y install build-essential cmake git libpoco-dev catch2 python3-dev

WORKDIR /tmp

RUN git clone https://gitlab.com/libeigen/eigen.git \
&& cd eigen \
&& git checkout 3.4.0 \
&& mkdir build && cd build \
&& cmake .. \
&& make install \
&& cd /tmp && rm -rf eigen

RUN git clone https://github.com/catchorg/Catch2.git \
&& cd Catch2 \
&& git checkout v2.13.8 \
&& mkdir build && cd build \
&& cmake -DCATCH_BUILD_TESTING=OFF -DCATCH_ENABLE_WERROR=OFF -DCATCH_INSTALL_DOCS=OFF -DCATCH_INSTALL_HELPERS=OFF .. \
&& make install \
&& cd /tmp && rm -rf Catch2

RUN git clone https://github.com/pybind/pybind11.git \
&& cd pybind11 \
&& git checkout v2.11.1 \
&& mkdir build && cd build \
&& cmake -DPYBIND11_TEST=OFF .. \
&& make -j$(nproc) \
&& make install \
&& cd /tmp && rm -rf pybind11

ARG LIBFRANKA_VERSION=0.13.3
RUN git clone --recursive https://github.com/frankaemika/libfranka.git \
&& cd libfranka \
&& git checkout "${LIBFRANKA_VERSION}" \
# Cherry-pick missing imports commit
&& git config user.email "[email protected]" \
&& git config user.name "John Doe" \
&& if ! git merge-base --is-ancestor f1f46fb HEAD; then git cherry-pick -m 1 f1f46fb; fi \
&& git submodule update \
&& mkdir build && cd build \
&& cmake -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF .. \
&& make -j$(nproc) \
&& make install \
&& cd /tmp && rm -rf libfranka
ADD dependency_versions /tmp/
ADD docker/common/ /tmp/common/
ARG LIBFRANKA_VERSION
RUN set -a && . /tmp/dependency_versions && set +a \
&& /tmp/common/install-dependencies

RUN git clone https://github.com/TimSchneider42/franky.git --recurse-submodules \
&& cd franky \
Expand All @@ -54,3 +18,6 @@ RUN git clone https://github.com/TimSchneider42/franky.git --recurse-submodules
&& make -j$(nproc) \
&& make install \
&& cd /tmp && rm -rf franky

# Cleaning up
RUN rm -rf /tmp/common

0 comments on commit c3e66e7

Please sign in to comment.