diff options
author | Ferdinand Thiessen <rpm@fthiessen.de> | 2022-06-14 19:40:55 +0300 |
---|---|---|
committer | Ferdinand Thiessen <rpm@fthiessen.de> | 2022-06-30 18:16:05 +0300 |
commit | f62c29be420b5bf856d337a3500b827299c3b042 (patch) | |
tree | fb65e170824a5cab1ab9a25f625e6a31f36ea0a6 | |
parent | bc26349fb23f2ee33927e70e2868236c25ebf8b2 (diff) |
Fix docker container for local cypress tests
Ensure correct file permissions after bind mount so nextcloud
can be installed without errors.
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
-rw-r--r-- | cypress/Dockerfile | 16 | ||||
-rw-r--r-- | cypress/docker-compose.yml | 3 | ||||
-rw-r--r-- | cypress/entrypoint.sh | 26 | ||||
-rwxr-xr-x | cypress/runLocal.sh | 6 | ||||
-rw-r--r-- | cypress/server.sh | 10 |
5 files changed, 33 insertions, 28 deletions
diff --git a/cypress/Dockerfile b/cypress/Dockerfile index ca343d110..71c0784c5 100644 --- a/cypress/Dockerfile +++ b/cypress/Dockerfile @@ -14,7 +14,9 @@ RUN set -ex; \ cd server; \ git submodule update --init; -RUN cp -r -v /usr/src/nextcloud/config /tmp/server +RUN set -ex; \ + cp -r -v /usr/src/nextcloud/config /tmp/server; \ + rm -rf /usr/src/nextcloud/apps/text; FROM nextcloud:latest @@ -22,7 +24,6 @@ RUN set -ex; \ rm -rf /usr/src/nextcloud; COPY --from=source --chown=www-data:www-data /tmp/server /usr/src/nextcloud -COPY --chown=www-data:www-data ./server.sh /tmp/server.sh RUN set -ex; \ cd /usr/src/nextcloud; \ @@ -34,13 +35,6 @@ ENV NEXTCLOUD_ADMIN_PASSWORD=admin ENV NEXTCLOUD_ADMIN_USER=admin ENV SQLITE_DATABASE=sqlite_db -RUN set -ex; \ - cd /var/www/html; \ - NEXTCLOUD_UPDATE=1 bash -x /entrypoint.sh pwd; \ - chown -R www-data:www-data config data apps custom_apps; \ - bash -x /tmp/server.sh; \ - rm -rf /var/www/html/apps/text +RUN mv /entrypoint.sh /original_entrypoint.sh -RUN set -ex; \ - cd /var/www/html; \ - ls -lah +COPY --chown=www-data:www-data --chmod=0755 ./entrypoint.sh /entrypoint.sh diff --git a/cypress/docker-compose.yml b/cypress/docker-compose.yml index dc37d403d..c6c2d1296 100644 --- a/cypress/docker-compose.yml +++ b/cypress/docker-compose.yml @@ -9,9 +9,6 @@ services: ports: - 8081:80 environment: - - NEXTCLOUD_ADMIN_PASSWORD=admin - - NEXTCLOUD_ADMIN_USER=admin - - SQLITE_DATABASE=sqlite_db - CYPRESS_baseUrl - APP_SOURCE volumes: diff --git a/cypress/entrypoint.sh b/cypress/entrypoint.sh new file mode 100644 index 000000000..8efe3d36d --- /dev/null +++ b/cypress/entrypoint.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Ensure correct permissions, as the bind-mount might currupt them (and prevent the installation) +[ -e /var/www/html/custom_apps ] && chown -R www-data:www-data /var/www/html/custom_apps > /dev/null 2>&1 + +NEXTCLOUD_UPDATE=1 +export NEXTCLOUD_UPDATE +OUTPUT=$(/original_entrypoint.sh true) + +echo "$OUTPUT" + +# Check if new installed +G=$(echo "$OUTPUT" | grep "New nextcloud instance") +if [ $? -eq 0 ]; then + echo "Nextcloud installed, fill demo data" + su -s /bin/bash www-data -c " + php /var/www/html/occ config:system:set debug --value='true' --type=boolean + export OC_PASS=1234561 + php /var/www/html/occ user:add --password-from-env user1 + php /var/www/html/occ user:add --password-from-env user2 + php /var/www/html/occ app:enable viewer + php /var/www/html/occ app:enable text + php /var/www/html/occ app:list + " +fi + +exec $@
\ No newline at end of file diff --git a/cypress/runLocal.sh b/cypress/runLocal.sh index 843079ea7..981d8b55f 100755 --- a/cypress/runLocal.sh +++ b/cypress/runLocal.sh @@ -25,11 +25,9 @@ then echo Server is up at "$CYPRESS_baseUrl" else echo No server reached at "$CYPRESS_baseUrl" - starting containers. - docker-compose up -d - if "$(npm bin)/wait-on" -i 500 -t 240000 "$CYPRESS_baseUrl" 2> /dev/null + DOCKER_BUILDKIT=1 docker-compose up -d + if ! "$(npm bin)/wait-on" -i 500 -t 240000 "$CYPRESS_baseUrl" 2> /dev/null then - docker-compose exec -T nextcloud_cypress bash /var/www/html/custom_apps/text/cypress/server.sh - else echo Waiting for "$CYPRESS_baseUrl" timed out. echo Container logs: docker-compose logs diff --git a/cypress/server.sh b/cypress/server.sh deleted file mode 100644 index 24f215d63..000000000 --- a/cypress/server.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -su -s /bin/bash www-data -c " -php /var/www/html/occ config:system:set debug --value='true' --type=boolean -export OC_PASS=1234561 -php /var/www/html/occ user:add --password-from-env user1 -php /var/www/html/occ user:add --password-from-env user2 -php /var/www/html/occ app:enable viewer -php /var/www/html/occ app:enable text -php /var/www/html/occ app:list -" |