From 2655231b4fdd3bc44b13e9800282873ecb608062 Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Sat, 25 Sep 2021 20:21:40 +0200 Subject: [PATCH] feat: add a script to build docker dev (#5531) --- .github/workflows/docker.yml | 17 ++----- .../DavClient/Utils/Dav/DavClient.php | 1 - .../DavClient/Utils/Dav/ServiceUrlQuery.php | 2 +- docs/contribute/docker.md | 19 ++++--- scripts/ci/package.sh | 2 +- scripts/docker/build.sh | 50 +++++++++++++++++++ scripts/{ci => }/realpath.sh | 0 scripts/tests/start-selenium.sh | 2 +- .../DavClient/Utils/Dav/DavClientTest.php | 2 +- 9 files changed, 70 insertions(+), 25 deletions(-) create mode 100755 scripts/docker/build.sh rename scripts/{ci => }/realpath.sh (100%) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 42134ed9022..3536ff5bafa 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -54,9 +54,6 @@ jobs: ${{ runner.os }}-composer-${{ env.php-version }} ${{ runner.os }}-composer- - - name: Install composer dependencies - run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - # Yarn - name: Setup Node.js uses: actions/setup-node@v2 @@ -74,17 +71,9 @@ jobs: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} ${{ runner.os }}-yarn- - - name: Install yarn dependencies - run: yarn inst - - name: Build assets - run: yarn run production - - # Complete setup - - name: Version files - run: | - git describe --abbrev=0 --tags | sed 's/^v//' > config/.version - git describe --abbrev=0 --tags --exact-match $GITHUB_SHA 2>/dev/null || git log --pretty="%h" -n1 $GITHUB_SHA > config/.release - echo $GITHUB_SHA > config/.commit + # Install + - name: Install + run: scripts/docker/build.sh --skip-build $GITHUB_SHA # Build docker - name: Docker build diff --git a/app/Services/DavClient/Utils/Dav/DavClient.php b/app/Services/DavClient/Utils/Dav/DavClient.php index a65a59e1a10..5a9400077cd 100644 --- a/app/Services/DavClient/Utils/Dav/DavClient.php +++ b/app/Services/DavClient/Utils/Dav/DavClient.php @@ -14,7 +14,6 @@ use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Exception\ClientException; use Sabre\CardDAV\Plugin as CardDAVPlugin; -use App\Services\DavClient\Utils\Traits\ServiceUrlQuery; class DavClient { diff --git a/app/Services/DavClient/Utils/Dav/ServiceUrlQuery.php b/app/Services/DavClient/Utils/Dav/ServiceUrlQuery.php index f36bcaf5509..24451168697 100644 --- a/app/Services/DavClient/Utils/Dav/ServiceUrlQuery.php +++ b/app/Services/DavClient/Utils/Dav/ServiceUrlQuery.php @@ -1,6 +1,6 @@ /dev/null || git --git-dir $ROOT/.git log --pretty="%h" -n1 $commit) +fi + +if [ -z "$tag" ]; then + tag=${1:-monica-dev} +fi + +echo Version +echo -n "$version" | tee config/.version + +echo -e "\nCommit" +echo -n "$commit" | tee config/.commit + +echo -e "\nRelease" +echo -n "$release" | tee config/.release + +echo -e "\n" + +# BUILD +composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader --no-dev --working-dir=$ROOT +yarn --cwd $ROOT run inst +yarn --cwd $ROOT run production + +# DOCKER BUILD +if [ "$tag" != "--skip-build" ]; then + docker build -t $tag -f $SELF_PATH/Dockerfile $ROOT + rm -f config/.{version,commit,release} +fi diff --git a/scripts/ci/realpath.sh b/scripts/realpath.sh similarity index 100% rename from scripts/ci/realpath.sh rename to scripts/realpath.sh diff --git a/scripts/tests/start-selenium.sh b/scripts/tests/start-selenium.sh index 5dccb32978f..cafafa08d67 100755 --- a/scripts/tests/start-selenium.sh +++ b/scripts/tests/start-selenium.sh @@ -3,7 +3,7 @@ set -evuo pipefail SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && /bin/pwd -P) -source $SELF_PATH/../ci/realpath.sh +source $SELF_PATH/../realpath.sh ROOT=$(realpath $SELF_PATH/../..) if [ -z "${DISPLAY:-}" ]; then diff --git a/tests/Unit/Services/DavClient/Utils/Dav/DavClientTest.php b/tests/Unit/Services/DavClient/Utils/Dav/DavClientTest.php index af482737c1c..0dc9ed5c060 100644 --- a/tests/Unit/Services/DavClient/Utils/Dav/DavClientTest.php +++ b/tests/Unit/Services/DavClient/Utils/Dav/DavClientTest.php @@ -1,6 +1,6 @@