Skip to content

Commit

Permalink
feat: add a script to build docker dev (#5531)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Sep 25, 2021
1 parent 38c8e9e commit 2655231
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 25 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/Services/DavClient/Utils/Dav/DavClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion app/Services/DavClient/Utils/Dav/ServiceUrlQuery.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Services\DavClient\Utils\Traits;
namespace App\Services\DavClient\Utils\Dav;

use GuzzleHttp\Psr7\Uri;
use Illuminate\Support\Arr;
Expand Down
19 changes: 13 additions & 6 deletions docs/contribute/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,22 @@ your Monica container.
If you aren't using docker-compose, edit `.env` again to set the `DB_*` variables to match your database. Then run:

```sh
# assets are copied from the host machine, make sure they are built
yarn install && yarn run production
scripts/docker/build.sh
```

docker build -t monicahq/monicahq -f scripts/docker/Dockerfile .
You can add the tag name as a parameter:
```sh
scripts/docker/build.sh monica-dev
```

docker run --env-file .env -p 80:80 monicahq/monicahq # to run MonicaHQ
Run monica with:
```sh
docker run --env-file .env -p 80:80 monica-dev
```

# ...or...
docker run --env-file .env -it monicahq/monicahq sh # to get a prompt
Or run a command in the container:
```sh
docker run --env-file .env -it monica-dev bash
```

There's a bunch of [docker-compose examples here.](https://github.com/monicahq/docker/tree/master/.examples)
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eo pipefail

SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && /bin/pwd -P)
source $SELF_PATH/realpath.sh
source $SELF_PATH/../realpath.sh
ROOT=$(realpath $SELF_PATH/../..)

version=$1
Expand Down
50 changes: 50 additions & 0 deletions scripts/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

set -eo pipefail

SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && /bin/pwd -P)
source $SELF_PATH/../realpath.sh
ROOT=$(realpath $SELF_PATH/../..)

version=$(git --git-dir $ROOT/.git describe --abbrev=0 --tags | sed 's/^v//')

commit=$1
if [ "$commit" == "--skip-build" ]; then
shift
tag=$commit
commit=$1
fi

if [ -z "$commit" ]; then
commit=$(git --git-dir $ROOT/.git log --pretty="%H" -n1 HEAD)
release=$(git --git-dir $ROOT/.git log --pretty="%h" -n1 HEAD)
else
shift
release=$(git --git-dir $ROOT/.git describe --abbrev=0 --tags --exact-match $commit 2>/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
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/tests/start-selenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Services/DavClient/Utils/Dav/DavClientTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\Unit\Services\DavClient\Utils;
namespace Tests\Unit\Services\DavClient\Utils\Dav;

use Tests\TestCase;
use Tests\Helpers\DavTester;
Expand Down

0 comments on commit 2655231

Please sign in to comment.