diff --git a/Dockerfile b/Dockerfile
index aaf1b5487255bd8c45d846d12580e4d9ae9d5d08..0f17358d5bcd4b116200b1ea745b5a061fa986e5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,11 +1,13 @@
-FROM debian:stable-slim AS authbuild
+# Build using the jupyterhub image to ensure compatibility of
+# the Python wheels that we're going to install later.
+FROM quay.io/jupyterhub/jupyterhub:5 AS authbuild
 
 RUN apt-get -q update \
-    && env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git ca-certificates python3-minimal python3-pip python3-dev build-essential
+    && env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git ca-certificates python3-dev build-essential
 RUN git clone https://git.autistici.org/labpopai/jupyterhub-authenticator /src
 RUN cd /src \
     && mkdir wheels \
-    && pip3 wheel -w wheels -e .
+    && pip wheel -w wheels -e .
 
 FROM quay.io/jupyterhub/jupyterhub:5
 RUN pip install --no-cache-dir dockerspawner