2021-10-24 01:00:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
. .env
|
|
|
|
|
2021-10-24 01:46:50 +00:00
|
|
|
DOCKER_WEB_IMAGE_NAME="ghcr.io/opdavies/${COMPOSE_PROJECT_NAME}-web"
|
|
|
|
|
2021-10-24 01:00:23 +00:00
|
|
|
TTY=""
|
|
|
|
if [[ ! -t 1 ]]; then
|
|
|
|
TTY="-T"
|
|
|
|
fi
|
|
|
|
|
2021-10-24 08:29:44 +00:00
|
|
|
DC="${DC:-exec}"
|
|
|
|
|
2021-10-24 01:00:23 +00:00
|
|
|
function cmd {
|
|
|
|
# Run any command in the app container.
|
|
|
|
_dc app "${@}"
|
|
|
|
}
|
|
|
|
|
2021-10-24 08:29:44 +00:00
|
|
|
function composer {
|
|
|
|
DC=run
|
|
|
|
_dc --entrypoint composer app "${@}"
|
|
|
|
}
|
|
|
|
|
2021-10-24 01:00:23 +00:00
|
|
|
function deploy {
|
|
|
|
cd tools/deployment && ansible-playbook deploy.yml
|
|
|
|
}
|
|
|
|
|
|
|
|
function docker:build-images {
|
2021-10-24 01:55:46 +00:00
|
|
|
docker image build . \
|
|
|
|
--file tools/docker/images/Dockerfile \
|
|
|
|
--tag ${DOCKER_WEB_IMAGE_NAME}:${DOCKER_TAG} \
|
|
|
|
--tag ${DOCKER_WEB_IMAGE_NAME}:latest \
|
|
|
|
--target=production
|
2021-10-24 01:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function docker:push-images {
|
2021-10-24 01:55:46 +00:00
|
|
|
docker image push ${DOCKER_WEB_IMAGE_NAME}:${DOCKER_TAG}
|
|
|
|
docker image push ${DOCKER_WEB_IMAGE_NAME}:latest
|
2021-10-24 01:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function help {
|
|
|
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
|
|
|
|
|
|
|
compgen -A function | grep -v "^_" | cat -n
|
|
|
|
|
|
|
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
function run-production {
|
|
|
|
docker-compose --file docker-compose-production.yaml up --detach --remove-orphans
|
|
|
|
}
|
|
|
|
|
2021-10-24 08:29:44 +00:00
|
|
|
function sh {
|
|
|
|
DC=run
|
|
|
|
_dc --entrypoint sh app
|
|
|
|
}
|
|
|
|
|
|
|
|
function test:quality {
|
|
|
|
DC=run
|
|
|
|
_dc --entrypoint phpstan app "${@}" analyze --memory-limit=-1
|
|
|
|
}
|
|
|
|
|
|
|
|
function test:unit {
|
|
|
|
DC=run
|
|
|
|
_dc --entrypoint phpunit app "${@}"
|
|
|
|
}
|
|
|
|
|
2021-10-24 01:00:23 +00:00
|
|
|
function _dc {
|
2021-10-24 08:29:44 +00:00
|
|
|
docker-compose ${DC} ${TTY} "${@}"
|
2021-10-24 01:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eval "${@:-help}"
|