-
Notifications
You must be signed in to change notification settings - Fork 1
/
.ahoy.yml
207 lines (176 loc) · 7.46 KB
/
.ahoy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
---
ahoyapi: v2
commands:
build:
usage: Build or rebuild project.
cmd: |
ahoy clean \
&& if [ "$COMPOSER" != "composer.json" ]; then ahoy composer-merge; fi \
&& if [ "$COMPOSER" != "composer.json" ]; then ahoy link-package; fi \
&& (docker network prune -f > /dev/null && docker network inspect amazeeio-network > /dev/null || docker network create amazeeio-network) \
&& ahoy up -- --build --force-recreate \
&& ahoy install-dev \
&& if [ "$COMPOSER" != "composer.json" ] && [ "$DRUPAL_PROFILE" ]; then ahoy init-profile; fi \
&& ahoy install-site \
&& if [ "$COMPOSER" != "composer.json" ]; then ahoy init-module; fi \
&& if [ "$COMPOSER" != "composer.json" ]; then ahoy drush pm-enable tide_test -y; fi \
&& ahoy line "Build complete" \
&& ahoy info 1
info:
usage: Print information about this project.
cmd: |
ahoy line "Site URL : " ${LOCALDEV_URL}:${LOCAL_PORT:-80}/
ahoy line "Path to project : " ${APP}
ahoy line "Path to docroot : " ${APP}/${WEBROOT}
ahoy line "DB port on host : " $(docker port $(docker-compose ps -q mariadb) 3306 | cut -d : -f 2)
ahoy line "Mailhog URL : " http://mailhog.docker.internal:${LOCAL_PORT:-80}/
if [ "$1" ]; then
ahoy line "One-time login : " $(ahoy login -- --no-browser)
fi
up:
usage: Build and start Docker containers.
cmd: |
docker-compose up -d "$@" \
&& ahoy cli "dockerize -wait tcp://mariadb:3306 -timeout 1m" \
&& if docker-compose logs | grep -q "\[Error\]"; then docker-compose logs; exit 1; fi \
&& docker ps -a --filter name=^/${COMPOSE_PROJECT_NAME}_ &&
# Add Bay SSH key before fetching DB.
# During local development, pygmy injects SSH key from the host, so specifying
# key as $BAY_KEY environment variable is not required (the host key of every
# developer must be added to Bay during project onboarding).
if [ "$BAY_KEY" ]; then
ahoy cli "mkdir -p /home/.ssh && echo -e \"$BAY_KEY\" > /home/.ssh/key && chmod 600 /home/.ssh/key;"
fi
down:
usage: Stop Docker containers and remove container, images, volumes and networks.
cmd: docker-compose down --volumes
start:
usage: Start existing Docker containers.
cmd: docker-compose start "$@"
stop:
usage: Stop running Docker containers.
cmd: docker-compose stop "$@"
restart:
usage: Restart all stopped and running Docker containers.
cmd: docker-compose restart
logs:
usage: Show Docker logs.
cmd: docker-compose logs "$@"
pull:
usage: Pull latest docker images.
cmd: |
docker image ls --format \"{{.Repository}}:{{.Tag}}\" | grep singledigital/ | grep -v none | xargs -n1 docker pull | cat \
&& docker image ls --format \"{{.Repository}}:{{.Tag}}\" | grep amazeeio/ | grep -v none | xargs -n1 docker pull | cat
cli:
usage: Start a shell inside CLI container or run a command.
cmd: if \[ "$@" \]; then docker exec -i $(docker-compose ps -q cli) bash -c "$@"; else docker exec -it $(docker-compose ps -q cli) bash; fi
drush:
usage: Run drush commands in the CLI service container.
cmd: docker exec -i $(docker-compose ps -q cli) drush -r ${APP}/${WEBROOT} -l ${LOCALDEV_URL} "$@"
login:
usage: Login to a website.
cmd: ahoy drush user:unblock -q "$(ahoy drush user:information --uid=1 --fields=name --format=string)" 2>/dev/null && ahoy drush user:login --no-browser
doctor:
usage: Find problems with current project setup.
cmd: scripts/doctor.sh
# @note: Call this on the host before starting containers.
composer-merge:
usage: Merge composer files.
cmd: scripts/composer-merge.sh
install-dev:
usage: Install dependencies.
cmd: ahoy cli "composer install -n --ansi --prefer-dist --no-suggest"
install-site:
usage: Install site.
cmd: |
ahoy flush-redis
if [ "$INSTALL_NEW_SITE" == "1" ]; then
ahoy cli -- ./scripts/drupal/install-new-site.sh
else
ahoy cli -- ./scripts/rebuild-env.sh
fi
db-import:
usage: Import the production database.
cmd: ahoy cli -- ./scripts/rebuild-env.sh
fix-bay-token:
usage: Fix the bay token by re-importing.
cmd: |
pygmy stop \
&& sleep 1 \
&& pygmy start \
&& docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs docker rm \
&& docker-compose up -d --force \
&& pygmy stop \
&& sleep 1 \
&& pygmy start
link-package:
usage: Link package from current repository root.
cmd: scripts/link-package.sh
hide: true
init-module:
usage: Install a module from current repository root.
cmd: ahoy cli "INSTALL_SUGGEST=$INSTALL_SUGGEST scripts/drupal-init-module.sh"
hide: true
init-profile:
usage: Install a profile from current repository root.
cmd: ahoy cli "INSTALL_SUGGEST=$INSTALL_SUGGEST scripts/drupal-init-profile.sh"
hide: true
clean:
usage: Remove all build files.
cmd: |
ahoy down \
&& ([ -d .git ] && git ls-files --directory --other -i --exclude-from=.gitignore ${WEBROOT} | grep -v "settings.local.php" | grep -v "services.local.yml" | xargs chmod -Rf 777 || true) \
&& ([ -d .git ] && git ls-files --directory --other -i --exclude-from=.gitignore ${WEBROOT} | grep -v "settings.local.php" | grep -v "services.local.yml" | xargs rm -Rf || true) \
&& rm -Rf vendor \
&& rm -Rf screenshots \
&& rm -Rf composer.build.*
clean-full:
usage: Remove all development files.
cmd: |
ahoy clean \
&& ([ -d .git ] && git ls-files --directory --other . | grep -v ".idea" | xargs chmod -Rf 777 || true) \
&& ([ -d .git ] && git ls-files --directory --other . | grep -v ".idea" | xargs rm -Rf || true)
deploy:
usage: Deploy or re-deploy a branch in Bay.
cmd: ./scripts/bay-deploy.sh "$@"
lint:
usage: Lint code.
cmd: ahoy cli "vendor/bin/phpcs ${PHPCS_TARGETS}"
lint-fix:
usage: Fix lint errors.
cmd: ahoy cli "vendor/bin/phpcbf ${PHPCS_TARGETS}"
test-behat:
usage: Run Behat tests.
cmd: ahoy cli "./vendor/bin/behat --strict --colors ${BEHAT_PROFILE} $@"
flush-redis:
usage: Flush Redis cache.
cmd: docker exec -i $(docker-compose ps -q redis) redis-cli flushall > /dev/null
set-dev-tools-commit:
usage: Specify a commit of Dev-Tools to downloaded and commit the result.
cmd: sed -i '' 's/.*GH_COMMIT.*/'"export GH_COMMIT=$1"'/' dev-tools.sh
# Utilities.
line:
cmd: printf "$(tput -Txterm setaf 2)${1}$(tput -Txterm sgr0)${2}\n"
hide: true
entrypoint:
- bash
- "-c"
- |
[ -f .env ] && export $(grep -v '^#' .env | xargs) && [ -f .env.local ] && export $(grep -v '^#' .env.local | xargs)
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
export PROJECT_NAME=${PROJECT_NAME:-$(basename $(pwd))}
export APP=${APP:-/app}
export WEBROOT=${WEBROOT:-docroot}
export MYSQL_HOST=${MYSQL_HOST:-mariadb}
export MYSQL_PORT=${MYSQL_PORT:-3306}
export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-$PROJECT_NAME}
export LOCALDEV_URL=${LOCALDEV_URL:-http://content-sdp.docker.internal}
export COMPOSER=${COMPOSER:-composer.json}
export DRUPAL_PROFILE=${DRUPAL_PROFILE:-}
export DRUPAL_MODULE_PREFIX=${DRUPAL_MODULE_PREFIX:-mysite}
PHPCS_TARGETS=${PHPCS_TARGETS:-.} && export PHPCS_TARGETS=${PHPCS_TARGETS//,/ }
if [ "$CI" ]; then export ES_TPL=elasticsearch.ci.yml; fi
bash -c "$0" "$@"
- '{{cmd}}'
- '{{name}}'