diff --git a/.docker/Dockerfile b/.docker/Dockerfile
index e549f2f4c329e93f0e357d084b9d86b5f4eae80e..42926cf783db3c63455f894931ffe3f3c9970852 100644
--- a/.docker/Dockerfile
+++ b/.docker/Dockerfile
@@ -1,3 +1,29 @@
+###############################
+###### Temporary Image ########
+###############################
+FROM debian:bookworm as git_base
+
+# Check for availability of DNS
+RUN if getent hosts indiscale.com > /dev/null; \
+    then echo "Connected to the internet and DNS available"; \
+    else echo "No internet connection or DNS not available"; \
+    fi
+
+RUN apt-get update && apt-get install -y \
+    git
+
+COPY . /git
+
+# Delete .git because it is huge.
+RUN rm -r /git/.git
+
+# Install pycaosdb.ini for the tests
+RUN mv /git/.docker/tester_pycaosdb.ini /git/integrationtests/pycaosdb.ini
+
+###############################
+###### Main Image Build #######
+###############################
+
 FROM debian:bookworm
 RUN apt-get update && \
     apt-get install \
@@ -16,13 +42,18 @@ RUN pip3 install --break-system-packages \
   sphinx-rtd-theme \
   ;
 COPY .docker/wait-for-it.sh /wait-for-it.sh
-COPY . /git
+ARG PYLIB
+ADD https://gitlab.indiscale.com/api/v4/projects/97/repository/commits/${PYLIB} \
+    pylib_version.json
+RUN git clone https://gitlab.indiscale.com/caosdb/src/caosdb-pylib.git && \
+    cd caosdb-pylib && git checkout ${PYLIB} && pip3 install --break-system-packages .
+ARG ADVANCED
+ADD https://gitlab.indiscale.com/api/v4/projects/104/repository/commits/${ADVANCED} \
+    advanced_version.json
+RUN git clone https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools.git && \
+    cd caosdb-advanced-user-tools && git checkout ${ADVANCED} && pip3 install --break-system-packages .[h5-crawler]
 
-# Delete .git because it is huge.
-RUN rm -r /git/.git
-
-# Install pycaosdb.ini for the tests
-RUN mv /git/.docker/tester_pycaosdb.ini /git/integrationtests/pycaosdb.ini
+COPY --from=git_base /git /git
 
 RUN cd /git/ && pip3 install --break-system-packages .[h5-crawler,spss,rocrate]