diff options
author | Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> | 2022-05-04 23:28:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 23:28:45 +0300 |
commit | 42df5736d6b94080b27dbbdbc295222646984f2b (patch) | |
tree | 28f53469dc993f2735dfcb652c457e18e5e0e567 | |
parent | b013c046eb60a1bef807ef1b04194ee8d2172032 (diff) | |
parent | e69d3c4acb42e8ab6b05b9c1cee261a6f35501eb (diff) |
Add CI/CD workflow for docker integration tests
-rw-r--r-- | .github/workflows/build-docker.yml | 147 | ||||
-rw-r--r-- | .github/workflows/vm-tests.yml | 2 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rwxr-xr-x | bin/ncp-dist-upgrade | 4 | ||||
-rwxr-xr-x | build/build-docker.sh | 59 | ||||
-rw-r--r-- | build/docker/Dockerfile | 188 | ||||
-rw-r--r-- | build/docker/debian-ncp/Dockerfile | 20 | ||||
-rw-r--r-- | build/docker/lamp/Dockerfile | 52 | ||||
-rw-r--r-- | build/docker/nextcloud/Dockerfile | 52 | ||||
-rw-r--r-- | build/docker/nextcloudpi/Dockerfile | 70 | ||||
-rwxr-xr-x | tests/activation_tests.py | 3 | ||||
-rwxr-xr-x | tests/system_tests.py | 14 |
12 files changed, 394 insertions, 222 deletions
diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 00000000..dc2e96b6 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,147 @@ +# https://www.docker.com/blog/docker-v2-github-action-is-now-ga/ +# https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/ +# https://docs.github.com/en/actions/guides/publishing-docker-images + +name: 'Docker Integration Tests and Release' + +on: + push: + branches: + - "*" + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + arch: + - x86 + - armhf + - arm64 + fail-fast: false + steps: + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Login to docker + run: | + echo "${{ secrets.DOCKER_PASSWORD_INTERNAL }}" | docker login -u "${{ secrets.DOCKER_LOGIN_INTERNAL }}" --password-stdin + + - name: Build images + id: build-container + run: | + ./build/build-docker.sh "${{ matrix.arch }}" + docker tag "ownyourbits/nextcloudpi-${{ matrix.arch }}:latest" "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}" + docker push "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}" + + test: + needs: + - build + runs-on: ubuntu-latest + + strategy: + matrix: + arch: + - armhf + - x86 + - arm64 + fail-fast: false + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Login to docker + run: | + echo "${{ secrets.DOCKER_PASSWORD_INTERNAL }}" | docker login -u "${{ secrets.DOCKER_LOGIN_INTERNAL }}" --password-stdin + - name: Start ncp container + run: | + docker run -d --rm -p 8443:443 -p 4443:4443 --name nextcloudpi thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }} + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Firefox + uses: browser-actions/setup-firefox@latest + - name: Setup GeckoDriver + uses: browser-actions/setup-geckodriver@latest + - name: Setup Selenium + run: pip install selenium + + - name: Integration Tests + working-directory: ./tests + run: | + python activation_tests.py --no-gui localhost 8443 4443 || { + tail -n 20 geckodriver.log >&2 || true + echo "=======================" + echo "Activation test failed!" + echo "Container logs:" + echo "===========================================" + docker logs nextcloudpi + echo "Last lines of ncp.log:" + echo "===========================================" + docker exec nextcloudpi tail /var/log/ncp.log; + exit 1 + } + echo "Activation test successful" + python system_tests.py --no-ping --non-interactive || { + echo "System test failed!" + exit 1 + } + echo "System test successful" + python nextcloud_tests.py --no-gui localhost 8443 4443 || { + tail -n 20 geckodriver.log >&2 || true + echo "=======================" + echo "Nextcloud test failed!" + echo "Container logs:" + echo "===========================================" + docker logs nextcloudpi + echo "Last lines of ncp.log:" + echo "===========================================" + docker exec nextcloudpi tail /var/log/ncp.log; + exit 1 + } + echo "Nextcloud test successful" + + release: + needs: + - test + if: ${{ github.event_name == 'push' && github.github.ref_type == 'tag' }} + runs-on: ubuntu-latest + steps: + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Create manifest and push as tag to docker hub + run: | + . ./build/buildlib.sh + + for arch in x86 armhf arm64 + do + docker pull "thecalcaholic/ncp-internal-${arch}:${{ github.run_id }}" + docker tag "thecalcaholic/ncp-internal-${arch}:${{ github.run_id }}" "ownyourbits/nextcloudpi-${arch}:${version?}" + done + + docker manifest create ownyourbits/nextcloudpi:${version?} \ + ownyourbits/nextcloudpi-armhf:${version?} \ + ownyourbits/nextcloudpi-x86:${version?} \ + ownyourbits/nextcloudpi-arm64:${version?} + docker manifest push ownyourbits/nextcloudpi:${version?} + + - name: Create manifest and push as latest to docker hub + run: | + docker manifest create ownyourbits/nextcloudpi:latest \ + ownyourbits/nextcloudpi-armhf:latest \ + ownyourbits/nextcloudpi-x86:latest \ + ownyourbits/nextcloudpi-arm64:latest + docker manifest push ownyourbits/nextcloudpi:latest diff --git a/.github/workflows/vm-tests.yml b/.github/workflows/vm-tests.yml index 335c220f..e4b92996 100644 --- a/.github/workflows/vm-tests.yml +++ b/.github/workflows/vm-tests.yml @@ -331,7 +331,7 @@ jobs: cleanup-snapshots: if: ${{ always() }} needs: - - cleanup + - create-postactivation-snapshots runs-on: ubuntu-latest container: image: thecalcaholic/ncp-test-automation:latest @@ -13,8 +13,13 @@ This code also generates the NextCloudPi [docker image](https://hub.docker.com/r Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.com) +--- [![VM Integration Tests](https://github.com/nextcloud/nextcloudpi/workflows/VM%20Integration%20Tests/badge.svg)](https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml) +[![Docker Integration Tests](https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg)](https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml) + +--- + ## Features * Debian/Raspbian 11 Bullseye diff --git a/bin/ncp-dist-upgrade b/bin/ncp-dist-upgrade index 8b5ae006..d8b30858 100755 --- a/bin/ncp-dist-upgrade +++ b/bin/ncp-dist-upgrade @@ -69,8 +69,8 @@ apt-get dist-upgrade -y # install latest PHP version release_new=$(jq -r '.release' < "${new_cfg}") -# the default repo in bullseye is bullseye-security - except for Raspbian -[[ -f /usr/bin/raspi-config ]] || release_new="${release_new}-security" +# the default repo in bullseye is bullseye-security - use bullseye if it is not available +grep -v '#' /etc/apt/sources.list | grep 'bullseye-security' > /dev/null && release_new="${release_new}-security" php_ver_new=$(jq -r '.php_version' < "${new_cfg}") $APTINSTALL -t ${release_new} php${php_ver_new} php${php_ver_new}-curl php${php_ver_new}-gd php${php_ver_new}-fpm php${php_ver_new}-cli php${php_ver_new}-opcache \ diff --git a/build/build-docker.sh b/build/build-docker.sh index 41e8d56c..6a6ebf5c 100755 --- a/build/build-docker.sh +++ b/build/build-docker.sh @@ -11,34 +11,53 @@ release=$(jq -r .release < etc/ncp.cfg) function docker_build() { DOCKER_BUILDKIT=1 docker build --progress=plain . "$@"; } -function build_arch() -{ - local release="${1}" - local arch="${2}" - local arch_qemu="${3}" - local ncp_tag="${4:-$arch}" +build_arch() { + local target="${1?}" + local release="${2?}" + local arch="${3?}" + local arch_qemu="${4?}" + local suffix="${5:-$arch}" echo -e "\e[1m\n[ Build NCP Docker ${arch} ]\e[0m" + DOCKER_BUILDKIT=1 docker build --pull --progress=plain . -f build/docker/Dockerfile \ + --target "$target" -t "ownyourbits/$target-${suffix}:latest" \ + --cache-from "ownyourbits/nextcloudpi-${suffix}" --build-arg "release=$release" --build-arg "arch=${arch}" \ + --build-arg "arch_qemu=$arch_qemu" --build-arg "ncp_ver=${version?}" - docker_build -f build/docker/debian-ncp/Dockerfile -t ownyourbits/debian-ncp-${ncp_tag}:latest --pull --build-arg release=${release} --build-arg arch=${arch} --build-arg arch_qemu=${arch_qemu} - docker_build -f build/docker/lamp/Dockerfile -t ownyourbits/lamp-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} --build-arg arch_qemu=${arch_qemu} - docker_build -f build/docker/nextcloud/Dockerfile -t ownyourbits/nextcloud-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} --build-arg arch_qemu=${arch_qemu} - docker_build -f build/docker/nextcloudpi/Dockerfile -t ownyourbits/nextcloudpi-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} --build-arg arch_qemu=${arch_qemu} --build-arg ncp_ver=${version} + docker tag "ownyourbits/${target}-${suffix}:latest" "ownyourbits/${target}-${suffix}:${version}" +} + +get_arch_args() { - docker tag ownyourbits/debian-ncp-${ncp_tag}:latest ownyourbits/debian-ncp-${ncp_tag}:"${version}" - docker tag ownyourbits/lamp-${ncp_tag}:latest ownyourbits/lamp-${ncp_tag}:"${version}" - docker tag ownyourbits/nextcloud-${ncp_tag}:latest ownyourbits/nextcloud-${ncp_tag}:"${version}" - docker tag ownyourbits/nextcloudpi-${ncp_tag}:latest ownyourbits/nextcloudpi-${ncp_tag}:"${version}" + [[ "${1?}" =~ "x86" ]] && { echo "amd64 x86_64 x86"; return 0; } + [[ "$1" =~ "armhf" ]] && { echo "arm32v7 arm armhf"; return 0; } + [[ "$1" =~ "arm64" ]] && { echo "arm64v8 aarch64 arm64"; return 0; } + + echo -e "Unsupported architecture: '${arch}'!" + return 1 } -# make sure we don't accidentally include this -rm -f ncp-web/wizard.cfg +clean_workspace() { + # make sure we don't accidentally include this + rm -f ncp-web/wizard.cfg +} -[[ "$@" =~ "x86" ]] && build_arch "${release}" amd64 x86_64 x86 -[[ "$@" =~ "armhf" ]] && build_arch "${release}" arm32v7 arm armhf -[[ "$@" =~ "arm64" ]] && build_arch "${release}" arm64v8 aarch64 arm64 +# Only execute script if not sourced +[[ "${BASH_SOURCE[0]}" == "$0" ]] && { + arch="${1?Missing argument: target architecture}" -exit 0 + shopt -s lastpipe + get_arch_args "$arch" | read -r -a arch_args + + # Pull latest image for caching + docker pull ownyourbits/nextcloudpi + for target in qemu nextcloudpi debian-ncp lamp nextcloud + do + build_arch "$target" "${release}" "${arch_args[@]}" + done + + exit 0 +} # License # diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile new file mode 100644 index 00000000..f2ec6904 --- /dev/null +++ b/build/docker/Dockerfile @@ -0,0 +1,188 @@ +ARG arch=armhf +ARG arch_qemu=arm +ARG release=bullseye +FROM debian:${release}-slim AS qemu + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends qemu-user-static + +FROM ${arch}/debian:${release}-slim as debian-ncp + +ARG arch_qemu + +LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" + +CMD /bin/bash + +COPY --from=qemu /usr/bin/qemu-${arch_qemu}-static /usr/bin/ + +RUN mkdir -p /etc/services-available.d /etc/services-enabled.d + +COPY build/docker/debian-ncp/run-parts.sh / + +# syntax=docker/dockerfile:experimental + +FROM --platform=linux/${arch_qemu} debian-ncp as lamp + +LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" + +SHELL ["/bin/bash", "-c"] + +ENV DOCKERBUILD 1 + +COPY etc/ncp.cfg etc/library.sh lamp.sh /usr/local/etc/ + +RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ +set -e; \ + +# installation +apt-get update; \ +apt-get install --no-install-recommends -y jq; \ + +source /usr/local/etc/library.sh; \ +set +x; \ +install_app /usr/local/etc/lamp.sh; \ + +# stop mysqld +mysqladmin -u root shutdown; \ + +# mariaDB fixups (move database to /data-ro, which will be in a persistent volume) +mkdir -p /data-ro /data; \ +mv /var/lib/mysql /data-ro/database; \ +sed -i "s|^datadir.*|datadir = /data-ro/database|" /etc/mysql/mariadb.conf.d/90-ncp.cnf; \ + +# package cleanup +apt-get autoremove -y; \ +apt-get clean; \ +find /var/lib/apt/lists -type f | xargs rm; \ +rm -rf /usr/share/man/*; \ +rm -rf /usr/share/doc/*; \ +rm /var/cache/debconf/*-old; \ +rm -f /var/log/alternatives.log /var/log/apt/*; \ + +# specific cleanup +rm /data-ro/database/ib_logfile*; \ +rm /usr/local/etc/lamp.sh + +COPY build/docker/lamp/010lamp /etc/services-enabled.d/ + +ENTRYPOINT ["/run-parts.sh"] + +EXPOSE 80 443 + +FROM --platform=linux/${arch_qemu} lamp as nextcloud +# syntax=docker/dockerfile:experimental + +ARG arch_qemu + +LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" + +SHELL ["/bin/bash", "-c"] + +ENV DOCKERBUILD 1 + +COPY etc/library.sh /usr/local/etc/ +COPY bin/ncp/CONFIG/nc-nextcloud.sh / +COPY etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/ +COPY etc/ncp-templates /usr/local/etc/ncp-templates + +RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ +set -e; \ + +# mark as image build +touch /.ncp-image; \ + +# mark as docker image +touch /.docker-image; \ + +# installation ( /var/www/nextcloud -> /data/app which will be in a volume ) +apt-get update; \ +apt-get install --no-install-recommends -y wget ca-certificates sudo jq; \ +source /usr/local/etc/library.sh; \ +install_app /nc-nextcloud.sh; \ +run_app_unsafe /nc-nextcloud.sh; \ +mv /var/www/nextcloud /data-ro/nextcloud; \ +ln -s /data-ro/nextcloud /var/www/nextcloud; \ + +# package cleanup +apt-get autoremove -y; \ +apt-get clean; \ +find /var/lib/apt/lists -type f | xargs rm; \ +rm -rf /usr/share/man/*; \ +rm -rf /usr/share/doc/*; \ +rm /var/cache/debconf/*-old; \ +rm -f /var/log/alternatives.log /var/log/apt/*; \ + +# specific cleanup +apt-get purge -y wget ca-certificates; \ +rm /nc-nextcloud.sh /usr/local/etc/ncp-config.d/nc-nextcloud.cfg; \ +rm /.ncp-image; + +COPY build/docker/nextcloud/020nextcloud /etc/services-enabled.d/ +COPY bin/ncp-provisioning.sh /usr/local/bin/ +# syntax=docker/dockerfile:experimental + +FROM --platform=linux/${arch_qemu} nextcloud as nextcloudpi + +ARG ncp_ver=v0.0.0 + +LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" + +SHELL ["/bin/bash", "-c"] + +ENV DOCKERBUILD 1 + +RUN mkdir -p /tmp/ncp-build +COPY bin/ /tmp/ncp-build/bin/ +COPY etc /tmp/ncp-build/etc/ +COPY ncp-web /tmp/ncp-build/ncp-web/ +COPY ncp-app /tmp/ncp-build/ncp-app/ +COPY ncp-previewgenerator /tmp/ncp-build/ncp-previewgenerator/ +COPY build/docker /tmp/ncp-build/build/docker/ +COPY ncp.sh update.sh post-inst.sh /tmp/ncp-build/ +COPY etc/ncp-config.d/nc-init.cfg /usr/local/etc/ncp-config.d/nc-init-copy.cfg + +RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ +set -e; \ + +# make sure we don't accidentally disable first run wizard +rm -f ncp-web/{wizard.cfg,ncp-web.cfg}; \ + +# mark as image build +touch /.ncp-image; \ + +# mark as docker image +touch /.docker-image; \ + +apt-get update; \ +apt-get install --no-install-recommends -y wget ca-certificates; \ + +# install nextcloudpi +source /usr/local/etc/library.sh; \ +cd /tmp/ncp-build/; \ +install_app ncp.sh; \ + +mv /usr/local/etc/ncp-config.d/nc-init-copy.cfg /usr/local/etc/ncp-config.d/nc-init.cfg; \ +run_app_unsafe bin/ncp/CONFIG/nc-init.sh; \ +sed -i 's|data-ro|data|' /data-ro/nextcloud/config/config.php; \ + +# fix default paths +sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.cfg; \ +sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup-auto.cfg; \ + +# cleanup all NCP extras +run_app_unsafe post-inst.sh; \ + +# specific cleanup +cd /; rm -r /tmp/ncp-build; \ +rm /usr/local/etc/ncp-config.d/nc-init.cfg; \ + +# package installation clean up +rm -rf /usr/share/man/*; \ +rm -rf /usr/share/doc/*; \ +rm -f /var/log/alternatives.log /var/log/apt/*; \ +rm /var/cache/debconf/*-old; \ + +# set version +echo "${ncp_ver}" > /usr/local/etc/ncp-version + +COPY build/docker/nextcloudpi/000ncp /etc/services-enabled.d/ diff --git a/build/docker/debian-ncp/Dockerfile b/build/docker/debian-ncp/Dockerfile deleted file mode 100644 index 35f319f8..00000000 --- a/build/docker/debian-ncp/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -ARG arch=armhf -ARG arch_qemu=arm -ARG release=bullseye -FROM debian:${release}-slim AS qemu - -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends qemu-user-static - -FROM ${arch}/debian:${release}-slim - -ARG arch_qemu - -LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" - -CMD /bin/bash - -COPY --from=qemu /usr/bin/qemu-${arch_qemu}-static /usr/bin/ - -RUN mkdir -p /etc/services-available.d /etc/services-enabled.d - -COPY build/docker/debian-ncp/run-parts.sh / diff --git a/build/docker/lamp/Dockerfile b/build/docker/lamp/Dockerfile deleted file mode 100644 index 4ed99602..00000000 --- a/build/docker/lamp/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -# syntax=docker/dockerfile:experimental - -ARG arch=armhf -ARG arch_qemu=arm - -FROM --platform=linux/${arch_qemu} ownyourbits/debian-ncp-${arch} - -LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" - -SHELL ["/bin/bash", "-c"] - -ENV DOCKERBUILD 1 - -COPY etc/ncp.cfg etc/library.sh lamp.sh /usr/local/etc/ - -RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ -set -e; \ - -# installation -apt-get update; \ -apt-get install --no-install-recommends -y jq; \ - -source /usr/local/etc/library.sh; \ -set +x; \ -install_app /usr/local/etc/lamp.sh; \ - -# stop mysqld -mysqladmin -u root shutdown; \ - -# mariaDB fixups (move database to /data-ro, which will be in a persistent volume) -mkdir -p /data-ro /data; \ -mv /var/lib/mysql /data-ro/database; \ -sed -i "s|^datadir.*|datadir = /data-ro/database|" /etc/mysql/mariadb.conf.d/90-ncp.cnf; \ - -# package cleanup -apt-get autoremove -y; \ -apt-get clean; \ -find /var/lib/apt/lists -type f | xargs rm; \ -rm -rf /usr/share/man/*; \ -rm -rf /usr/share/doc/*; \ -rm /var/cache/debconf/*-old; \ -rm -f /var/log/alternatives.log /var/log/apt/*; \ - -# specific cleanup -rm /data-ro/database/ib_logfile*; \ -rm /usr/local/etc/lamp.sh - -COPY build/docker/lamp/010lamp /etc/services-enabled.d/ - -ENTRYPOINT ["/run-parts.sh"] - -EXPOSE 80 443 diff --git a/build/docker/nextcloud/Dockerfile b/build/docker/nextcloud/Dockerfile deleted file mode 100644 index cde0cd48..00000000 --- a/build/docker/nextcloud/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -# syntax=docker/dockerfile:experimental - -ARG arch=armhf -ARG arch_qemu=arm - -FROM --platform=linux/${arch_qemu} ownyourbits/lamp-${arch} - -LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" - -SHELL ["/bin/bash", "-c"] - -ENV DOCKERBUILD 1 - -COPY etc/library.sh /usr/local/etc/ -COPY bin/ncp/CONFIG/nc-nextcloud.sh / -COPY etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/ -COPY etc/ncp-templates /usr/local/etc/ncp-templates - -RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ -set -e; \ - -# mark as image build -touch /.ncp-image; \ - -# mark as docker image -touch /.docker-image; \ - -# installation ( /var/www/nextcloud -> /data/app which will be in a volume ) -apt-get update; \ -apt-get install --no-install-recommends -y wget ca-certificates sudo jq; \ -source /usr/local/etc/library.sh; \ -install_app /nc-nextcloud.sh; \ -run_app_unsafe /nc-nextcloud.sh; \ -mv /var/www/nextcloud /data-ro/nextcloud; \ -ln -s /data-ro/nextcloud /var/www/nextcloud; \ - -# package cleanup -apt-get autoremove -y; \ -apt-get clean; \ -find /var/lib/apt/lists -type f | xargs rm; \ -rm -rf /usr/share/man/*; \ -rm -rf /usr/share/doc/*; \ -rm /var/cache/debconf/*-old; \ -rm -f /var/log/alternatives.log /var/log/apt/*; \ - -# specific cleanup -apt-get purge -y wget ca-certificates; \ -rm /nc-nextcloud.sh /usr/local/etc/ncp-config.d/nc-nextcloud.cfg; \ -rm /.ncp-image; - -COPY build/docker/nextcloud/020nextcloud /etc/services-enabled.d/ -COPY bin/ncp-provisioning.sh /usr/local/bin/ diff --git a/build/docker/nextcloudpi/Dockerfile b/build/docker/nextcloudpi/Dockerfile deleted file mode 100644 index e5920548..00000000 --- a/build/docker/nextcloudpi/Dockerfile +++ /dev/null @@ -1,70 +0,0 @@ -# syntax=docker/dockerfile:experimental - -ARG arch=armhf -ARG arch_qemu=arm - -FROM --platform=linux/${arch_qemu} ownyourbits/nextcloud-${arch} - -ARG ncp_ver=v0.0.0 - -LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" - -SHELL ["/bin/bash", "-c"] - -ENV DOCKERBUILD 1 - -RUN mkdir -p /tmp/ncp-build -COPY bin/ /tmp/ncp-build/bin/ -COPY etc /tmp/ncp-build/etc/ -COPY ncp-web /tmp/ncp-build/ncp-web/ -COPY ncp-app /tmp/ncp-build/ncp-app/ -COPY ncp-previewgenerator /tmp/ncp-build/ncp-previewgenerator/ -COPY build/docker /tmp/ncp-build/build/docker/ -COPY ncp.sh update.sh post-inst.sh /tmp/ncp-build/ -COPY etc/ncp-config.d/nc-init.cfg /usr/local/etc/ncp-config.d/nc-init-copy.cfg - -RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ -set -e; \ - -# make sure we don't accidentally disable first run wizard -rm -f ncp-web/{wizard.cfg,ncp-web.cfg}; \ - -# mark as image build -touch /.ncp-image; \ - -# mark as docker image -touch /.docker-image; \ - -apt-get update; \ -apt-get install --no-install-recommends -y wget ca-certificates; \ - -# install nextcloudpi -source /usr/local/etc/library.sh; \ -cd /tmp/ncp-build/; \ -install_app ncp.sh; \ - -mv /usr/local/etc/ncp-config.d/nc-init-copy.cfg /usr/local/etc/ncp-config.d/nc-init.cfg; \ -run_app_unsafe bin/ncp/CONFIG/nc-init.sh; \ -sed -i 's|data-ro|data|' /data-ro/nextcloud/config/config.php; \ - -# fix default paths -sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.cfg; \ -sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup-auto.cfg; \ - -# cleanup all NCP extras -run_app_unsafe post-inst.sh; \ - -# specific cleanup -cd /; rm -r /tmp/ncp-build; \ -rm /usr/local/etc/ncp-config.d/nc-init.cfg; \ - -# package installation clean up -rm -rf /usr/share/man/*; \ -rm -rf /usr/share/doc/*; \ -rm -f /var/log/alternatives.log /var/log/apt/*; \ -rm /var/cache/debconf/*-old; \ - -# set version -echo "${ncp_ver}" > /usr/local/etc/ncp-version - -COPY build/docker/nextcloudpi/000ncp /etc/services-enabled.d/ diff --git a/tests/activation_tests.py b/tests/activation_tests.py index bbc59a66..1def55c9 100755 --- a/tests/activation_tests.py +++ b/tests/activation_tests.py @@ -32,6 +32,7 @@ from selenium.common.exceptions import TimeoutException suite_name = "activation tests" test_cfg = 'test_cfg.txt' test_log = 'test_log.txt' +wait_timeout = 120 class tc: @@ -121,7 +122,7 @@ def test_activation(IP, nc_port, admin_port, options): test.new("activation ends") try: - wait = WebDriverWait(driver, 60) + wait = WebDriverWait(driver, wait_timeout) wait.until(EC.text_to_be_present_in_element((By.ID,'error-box'), "ACTIVATION SUCCESSFUL")) test.check(True) except TimeoutException: diff --git a/tests/system_tests.py b/tests/system_tests.py index e722b551..a2e56511 100755 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -181,18 +181,21 @@ if __name__ == "__main__": # parse options try: - opts, args = getopt.getopt(sys.argv[1:], 'h', ['help', 'no-ping']) + opts, args = getopt.getopt(sys.argv[1:], 'h', ['help', 'no-ping', 'non-interactive']) except getopt.GetoptError: usage() sys.exit(2) skip_ping = False + interactive = True for opt, arg in opts: if opt in ('-h', '--help'): usage() sys.exit(2) elif opt == '--no-ping': skip_ping = True + elif opt == '--non-interactive': + interactive = False else: usage() sys.exit(2) @@ -208,7 +211,7 @@ if __name__ == "__main__": # detect if we are running this in a NCP instance try: - dockers_running = run(['docker', 'ps', '--format', '{{.Image}}'], stdout=PIPE).stdout.decode('utf-8') + dockers_running = run(['docker', 'ps', '--format', '{{.Names}}'], stdout=PIPE).stdout.decode('utf-8') except: dockers_running = '' @@ -226,9 +229,12 @@ if __name__ == "__main__": pre_cmd = [] # docker method - elif 'ownyourbits/nextcloudpi-' in dockers_running: + elif 'nextcloudpi' in dockers_running: print( tc.brown + "* local NCP docker instance detected" + tc.normal) - pre_cmd = ['docker', 'exec', '-ti', 'nextcloudpi'] + pre_cmd = ['docker', 'exec'] + if interactive: + pre_cmd.append('-ti') + pre_cmd.append('nextcloudpi') # LXC method elif lxc_running: |