drm_hwcomposer: Add support for running CI locally using docker

Prior to this commit running local CI script required the latest non-LTS
ubuntu installed.

To run CI on host run:

    make local_presubmit

To run CI within docker container run:

    make ci

With this commit we're also setting the stage for meson build.

Change-Id: I759c35ef8da306de8759f290c11c39c4b237bb8c
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/.ci/.gitlab-ci-checkcommit.sh b/.ci/.gitlab-ci-checkcommit.sh
index ff293a8..f854999 100755
--- a/.ci/.gitlab-ci-checkcommit.sh
+++ b/.ci/.gitlab-ci-checkcommit.sh
@@ -1,5 +1,13 @@
 #! /usr/bin/env bash
 
+check_tool_installed() {
+	if ! command -v $1 &> /dev/null
+	then
+		echo "Please install '$1' tool"
+		exit 1
+	fi
+}
+
 echoerr() {
 	printf "ERROR: %s\n" "$*" >&2
 }
@@ -27,6 +35,9 @@
 	return 1
 }
 
+check_tool_installed bpfmt
+check_tool_installed clang-format-diff-15
+
 git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git
 
 git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do
diff --git a/.ci/Dockerfile b/.ci/Dockerfile
new file mode 100644
index 0000000..d0ecee2
--- /dev/null
+++ b/.ci/Dockerfile
@@ -0,0 +1,44 @@
+FROM ubuntu:22.10
+
+ENV DEBIAN_FRONTEND=noninteractive
+
+ENV PATH="/home/user/bin:${PATH}"
+
+# Taking into account layer structure, everything should be done within one layer.
+RUN apt-get update && apt-get upgrade -y && \
+    apt-get install -y clang-15 clang-tidy-15 clang-format-15 git libdrm-dev blueprint-tools libgtest-dev clang llvm make python3 python3-pip wget sudo && \
+    pip3 install mako meson jinja2 ply pyyaml
+
+ENV RUN_USER user
+ENV RUN_UID 1000
+
+ENV USER_HOME /home/${RUN_USER}
+
+RUN mkdir -pv ${USER_HOME}
+# Create new user
+RUN adduser \
+    --gecos 'Build User' \
+    --shell '/usr/bin/bash' \
+    --uid ${RUN_UID} \
+    --disabled-login \
+    --disabled-password ${RUN_USER} \
+    && adduser ${RUN_USER} sudo
+
+RUN chown -R ${RUN_USER}:${RUN_USER} ${USER_HOME} && chmod -R 775 ${USER_HOME}
+
+# Ensure sudo group users are not
+# asked for a password when using
+# sudo command by ammending sudoers file
+RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> \
+/etc/sudoers
+
+# Pass control to a newly created user
+USER ${RUN_USER}
+
+# Create project path
+RUN mkdir -pv ${USER_HOME}/drm_hwcomposer
+WORKDIR ${USER_HOME}/drm_hwcomposer
+
+RUN git config --global user.name "FIRST_NAME LAST_NAME" && git config --global user.email "MY_NAME@example.com"
+
+CMD [ "/bin/bash" ]