Files
docker/hidche/app/entrypoint.sh
T

38 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -euxo pipefail
shopt -s nullglob
cp -n /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
printf "[PHP]\ndate.timezone = \"$TZ\"\n" > /usr/local/etc/php/conf.d/tzone.ini
wwwRoot="/var/www"
samRoot="$wwwRoot/html/sam"
imageRoot="$wwwRoot/html/image"
if [ ! -f "$samRoot/index.php" ]; then
echo generate $samRoot
mkdir -p $samRoot
chown -R www-data:www-data $wwwRoot
gosu www-data git clone $gameGitPath $samRoot
gosu www-data git checkout $gameGitBranch
pushd $samRoot
gosu www-data npm ci
gosu www-data npm run build -- --env target=gateway
gosu www-data php composer.phar install
popd
fi
if [ "$HIDCHE_IMAGE_USE_INTERNAL" = "yes" ] && [ ! -d "$imageRoot" ]; then
if [[ "$imgGitPath" =~ ^ssh ]]; then
query=`echo "<?php \\\$a=parse_url('$imgGitPath');echo join(' ', [\\\$a['port']?'-p '.\\\$a['port']:'',\\\$a['host']]);" | php`
gosu www-data ssh-keyscan $query >> /var/www/.ssh/known_hosts 2>/dev/null;
gosu www-data chmod 600 /var/www/.ssh/known_hosts
fi
echo generate $imageRoot
mkdir -p $imageRoot
chown -R www-data:www-data $imageRoot
gosu www-data git clone $imgGitPath $imageRoot
fi
exec "$@"