From 0c841de5b5500eec8938075366c4f9240a666961 Mon Sep 17 00:00:00 2001
From: Splines <37160523+Splines@users.noreply.github.com>
Date: Sat, 1 Jun 2024 15:20:35 +0200
Subject: [PATCH] Don't just mount `spec` folder, but complete `app` folder for
 tests (#648)

* Don't just mount `spec` folder, but complete `app` folder for tests

This is to ensure that local changes in the `app` folder are reflected
in the Docker container such that newly written tests can be run through
without having to rebuild the whole Docker image.

* Exclude `public/` folder from mount

Also see: https://stackoverflow.com/a/56361190/

* Copy everything to `usr/src/app` for precompiling to work & fix `public/` folder mount

Also see https://stackoverflow.com/a/37898591/
---
 docker/test/Dockerfile         |  3 ++-
 docker/test/docker-compose.yml | 10 +++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile
index 74cdc9b38..470e065f5 100644
--- a/docker/test/Dockerfile
+++ b/docker/test/Dockerfile
@@ -58,6 +58,7 @@ RUN apt update && \
 RUN sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml
 
 WORKDIR /usr/src/app
+ENTRYPOINT ["./entrypoint.sh"]
 
 COPY ./Gemfile ./Gemfile.lock ./yarn.lock ./package.json /usr/src/app/
 RUN bundle install
@@ -66,7 +67,7 @@ RUN yarn install --production=false
 COPY --from=build-pdfcomprezzor /go/src/pdfcomprezzor.wasm /go/src/wasm_exec.js /usr/src/app/public/pdfcomprezzor/
 COPY --from=build-pdfcomprezzor /go/src/pdfcomprezzor.wasm /go/src/wasm_exec.js /
 
-COPY . /usr/src/app/
+COPY . /usr/src/app
 COPY ./docker/production/docker.env ./docker-dummy.env
 
 RUN set -o allexport && . ./docker-dummy.env && set +o allexport && \
diff --git a/docker/test/docker-compose.yml b/docker/test/docker-compose.yml
index f8b21e7eb..eac665df1 100644
--- a/docker/test/docker-compose.yml
+++ b/docker/test/docker-compose.yml
@@ -37,9 +37,6 @@ services:
       context: ./../..
       dockerfile: docker/test/Dockerfile
     image: mampf:tests
-    # TODO: Use this
-    # entrypoint: /usr/src/app/docker/test/run_tests.sh
-    entrypoint: /usr/src/app/entrypoint.sh
     environment:
       RAILS_ENV: test
       TEST_DATABASE_ADAPTER: postgresql
@@ -68,10 +65,9 @@ services:
       SPROCKETS_CACHE: /cache
       BLOG: https://mampf.blog
     volumes:
-        - type: bind
-          source: ../../spec/
-          target: /usr/src/app/spec/
-        - ../../coverage:/usr/src/app/coverage
+      - ../../:/usr/src/app/
+      - ../../coverage:/usr/src/app/coverage/
+      - "/usr/src/app/public/"
     depends_on:
       - db
       - solr