From 0b57533b54832d6e28a5290205ff4bf20028845c Mon Sep 17 00:00:00 2001 From: ABeltramo Date: Thu, 1 Aug 2024 21:22:04 +0100 Subject: [PATCH] feat: added basic Dockerfile for compiling from scratch --- .dockerignore | 4 +++ bindings/rust/.dockerignore | 1 + docker/Dockerfile | 70 +++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 bindings/rust/.dockerignore create mode 100644 docker/Dockerfile diff --git a/.dockerignore b/.dockerignore index 92245fe..604a1c7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,7 @@ !include !cmake/ !docker/startup.sh +!share/ + +# Rust bindings +!bindings/rust/ diff --git a/bindings/rust/.dockerignore b/bindings/rust/.dockerignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/bindings/rust/.dockerignore @@ -0,0 +1 @@ +target/ diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..87f4d1c --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,70 @@ +ARG BASE_IMAGE=ghcr.io/games-on-whales/base:edge + +#################################### +FROM $BASE_IMAGE AS build-libinputtino + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + ccache \ + ninja-build \ + cmake \ + clang \ + pkg-config \ + git \ + libevdev-dev \ + && rm -rf /var/lib/apt/lists/* + + +COPY . /inputtino/ +WORKDIR /inputtino + +ENV CCACHE_DIR=/cache/ccache +ENV CMAKE_BUILD_DIR=/cache/cmake-build +RUN --mount=type=cache,target=/cache/ccache \ + cmake -B$CMAKE_BUILD_DIR \ + -DCMAKE_INSTALL_PREFIX:PATH=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_TESTING=OFF \ + -DBUILD_C_BINDINGS=ON \ + -DLIBINPUTTINO_INSTALL=ON \ + -DBUILD_SHARED_LIBS=ON \ + -G Ninja && \ + ninja -C $CMAKE_BUILD_DIR install + +#################################### +FROM $BASE_IMAGE AS base-libinputtino + +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends libevdev2 \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=build-libinputtino /usr/include/inputtino /usr/include/inputtino +COPY --from=build-libinputtino /usr/share/pkgconfig/libinputtino.pc /usr/share/pkgconfig/libinputtino.pc +COPY --from=build-libinputtino /usr/lib/x86_64-linux-gnu/liblibinputtino* /usr/lib/x86_64-linux-gnu/ + +#################################### +FROM base-libinputtino AS build-rust-bindings + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + pkg-config \ + build-essential \ + clang \ + curl \ + && curl https://sh.rustup.rs -sSf | bash -s -- -y \ + && rm -rf /var/lib/apt/lists/* + +ENV PATH="${HOME}/.cargo/bin:${PATH}" + +COPY ./bindings/rust /inputtino-rust +WORKDIR /inputtino-rust + + +RUN cargo build --release +