Skip to content

Commit

Permalink
feat: added basic Dockerfile for compiling from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
ABeltramo committed Aug 1, 2024
1 parent 5df6e1e commit 0b57533
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
!include
!cmake/
!docker/startup.sh
!share/

# Rust bindings
!bindings/rust/
1 change: 1 addition & 0 deletions bindings/rust/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
70 changes: 70 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0b57533

Please sign in to comment.