From 6ddf98ce906faf14642586a859ee1de19ae10a0a Mon Sep 17 00:00:00 2001 From: stev leibelt Date: Wed, 31 Jan 2024 10:27:13 +0100 Subject: [PATCH] Add docker scompose support to ease up setup. --- .gitignore | 3 ++ docker-compose.yml | 6 ++++ run.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .gitignore create mode 100644 docker-compose.yml create mode 100755 run.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a27059b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +adb.php +libraries/* +!libraries/placeholder diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..40a10a3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +services: + php-cli: + image: php:8.2-apache + restart: unless-stopped + volumes: + - .:/var/www/html diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..4782742 --- /dev/null +++ b/run.sh @@ -0,0 +1,76 @@ +#!/bin/bash +#### +# Setup environment to run application in a docker container +# +# @todo: +# +# +# @author: stev leibelt +# @since: 2024-01-31 +#### + +function _build () +{ + # stop execution if one comand fails + set -e + + local PATH_OF_THIS_SCRIPT + + PATH_OF_THIS_SCRIPT=$(realpath "$(dirname "${0}")") + + if [[ ! -f "${PATH_OF_THIS_SCRIPT}"/adb.php ]]; + then + wget -O "${PATH_OF_THIS_SCRIPT}"/adb.php https://raw.githubusercontent.com/MlgmXyysd/php-adb/master/src/adb.php + fi + + if [[ ! -f "${PATH_OF_THIS_SCRIPT}"/libraries/adb ]]; + then + wget -O "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip https://dl.google.com/android/repository/platform-tools_r34.0.5-linux.zip + unzip -d "${PATH_OF_THIS_SCRIPT}"/libraries "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip + rm "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip + mv "${PATH_OF_THIS_SCRIPT}"/libraries/platform-tools/* "${PATH_OF_THIS_SCRIPT}"/libraries/ + rmdir "${PATH_OF_THIS_SCRIPT}"/libraries/platform-tools + fi +} + +function _main () +{ + case "${1}" in + bulid) + _build + ;; + login) + _login + ;; + start) + _start + ;; + stop) + _stop + ;; + *) + echo "Usage: ${0} {build|login|start|stop}" + return 1 + ;; + esac +} + +function _login () +{ + _start + docker compose exec php-cli bash +} + +function _start () +{ + _stop + _build + docker compose up -d +} + +function _stop () +{ + docker compose down +} + +_main "${@}"