diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6fad501e80467cb75f9d0488fbea40623779d11d..5b592d63d8feb3ce12982c7992914da1502996b8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,37 @@
-image: alpine:latest
+.templates_sha: &template_sha dd90ac0d7a03b574eb4f18d7358083f0c97825f3
+
+include:
+  - project: 'freedesktop/ci-templates'
+    ref: *template_sha
+    file:
+      - '/templates/alpine.yml'
+
+stages:
+  - prep
+  - build
+  - deploy
+
+variables:
+  WAYLAND_PACKAGES: git build-base meson libffi-dev expat-dev doxygen libxslt xmlto graphviz ttf-dejavu
+  # libinput's .gitlab-ci.yml has the list of ALPINE_PACKAGES, copied from there
+  LIBINPUT_PACKAGES: git gcc build-base pkgconfig meson check-dev eudev-dev libevdev-dev libwacom-dev mtdev-dev bash doxygen graphviz py3-pip py3-sphinx py3-pytest-xdist
+  PIP_PACKAGES: recommonmark sphinx_rtd_theme
+  FDO_DISTRIBUTION_EXEC: "pip install --break-system-packages $PIP_PACKAGES"
+  FDO_DISTRIBUTION_PACKAGES: $WAYLAND_PACKAGES $LIBINPUT_PACKAGES
+  FDO_DISTRIBUTION_TAG: 2024-01-23.0
+  FDO_UPSTREAM_REPO: wayland/wayland.freedesktop.org
+
+container-build:
+  extends:
+    - .fdo.container-build@alpine
+  stage: prep
+  variables:
+    GIT_STRATEGY: none
 
 libinput:
+  extends:
+    - .fdo.distribution-image@alpine
   stage: build
-  before_script:
-  - apk add $ALPINE_PACKAGES
-  - pip3 install recommonmark sphinx_rtd_theme
   script:
   - git clone https://gitlab.freedesktop.org/libinput/libinput.git libinput.git
   - cd libinput.git
@@ -23,13 +50,13 @@ libinput:
   variables:
     MESON_ARGS: '-Ddebug-gui=false -Dtests=false -Ddocumentation=true'
     MESON_BUILDDIR: 'builddir'
-    # libinput's .gitlab-ci.yml has the list of ALPINE_PACKAGES, copied from there
-    ALPINE_PACKAGES:  'git gcc build-base pkgconfig meson check-dev eudev-dev libevdev-dev libwacom-dev mtdev-dev bash doxygen graphviz py3-pip py3-sphinx py3-pytest-xdist'
+  needs:
+    - container-build
 
 wayland:
+  extends:
+    - .fdo.distribution-image@alpine
   stage: build
-  before_script:
-  - apk add git build-base meson libffi-dev expat-dev doxygen libxslt xmlto graphviz ttf-dejavu
   script:
   - git clone https://gitlab.freedesktop.org/wayland/wayland.git
   - cd wayland
@@ -44,6 +71,8 @@ wayland:
   artifacts:
     paths:
     - docs/html
+  needs:
+    - container-build
 
 pages:
   stage: deploy