2023-12-22 23:44:48 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-01-01 01:14:38 +03:00
|
|
|
# Docker commands to build maketrandevu
|
2023-12-22 23:44:48 +03:00
|
|
|
# First setup docker and install alpine image
|
|
|
|
# Approximately 10min (tested with 4vcpu / 8GB RAM / 30Mbps network speed)
|
|
|
|
|
2024-01-01 01:14:38 +03:00
|
|
|
# MAKETRANDEVU_VER="test"
|
|
|
|
MAKETRANDEVU_VER="1.5.0-p1" # UPDATE MANUALLY !
|
2023-12-22 23:44:48 +03:00
|
|
|
|
|
|
|
_RED='\033[0;31m'
|
|
|
|
_NC='\033[0m \e[0m' # No Color, No Effect
|
|
|
|
if [[ $1 != "docker" ]]; then
|
2024-01-01 01:14:38 +03:00
|
|
|
if [[ $(pwd) != *maketrandevu/docker/build ]]; then
|
|
|
|
echo "PLEASE CHANGE DIRECTORY TO \`maketrandevu/docker/build\` BEFORE STARTING SCRIPT"
|
2023-12-22 23:44:48 +03:00
|
|
|
exit
|
|
|
|
fi
|
2024-01-01 01:14:38 +03:00
|
|
|
docker rm MAKETRANDEVU_BUILDER
|
2023-12-22 23:44:48 +03:00
|
|
|
echo "removed"
|
2024-01-01 01:14:38 +03:00
|
|
|
docker run -it -d --name MAKETRANDEVU_BUILDER --mount type=bind,source=".",target=/link/ alpine:latest "/bin/sh"
|
2023-12-22 23:44:48 +03:00
|
|
|
echo -e "RUN COMMANDS IN ALPINE DOCKER"
|
|
|
|
echo -e "RUN SCRIPT: \`${_RED}apk add bash && bash /link/docker.sh docker${_NC}\`"
|
2024-01-01 01:14:38 +03:00
|
|
|
docker attach MAKETRANDEVU_BUILDER --detach-keys="ctrl-k"
|
2023-12-22 23:44:48 +03:00
|
|
|
echo "EXIT"
|
|
|
|
exit
|
|
|
|
elif [[ $1 == "docker" ]]; then
|
|
|
|
set -x
|
|
|
|
# Inside Alpine Docker
|
|
|
|
apk update && apk upgrade
|
|
|
|
apk add git npm composer
|
|
|
|
apk add php-gd php-dom php-xml php-xmlwriter phpunit
|
|
|
|
|
|
|
|
mkdir /docker_build/
|
2024-01-01 01:14:38 +03:00
|
|
|
cd /docker_build/ || exit
|
|
|
|
git clone https://git.aliberksandikci.com.tr/maket/maketrandevu
|
|
|
|
cd maketrandevu || exit
|
2023-12-22 23:44:48 +03:00
|
|
|
|
|
|
|
composer update
|
|
|
|
composer upgrade
|
|
|
|
npm audit fix # maybe no need ?
|
|
|
|
npm install
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo -e "${_RED}SUCCESS${_NC}"
|
|
|
|
mkdir -p /status/success
|
|
|
|
touch /status/success/npm
|
|
|
|
else
|
|
|
|
echo -e "${_RED}FAIL${_NC}"
|
|
|
|
mkdir -p /status/fail
|
|
|
|
touch /status/fail/npm
|
|
|
|
fi
|
|
|
|
echo -e "${_RED}!SEE RESULT ABOVE!${_NC}"
|
|
|
|
echo "waiting before composer install(10)"
|
|
|
|
sleep 10
|
|
|
|
|
|
|
|
composer install
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo -e "${_RED}SUCCESS${_NC}"
|
|
|
|
mkdir -p /status/success
|
|
|
|
touch /status/success/composer
|
|
|
|
else
|
|
|
|
echo -e "${_RED}FAIL${_NC}"
|
|
|
|
mkdir -p /status/fail
|
|
|
|
touch /status/fail/composer
|
|
|
|
fi
|
|
|
|
echo -e "${_RED}!SEE RESULT ABOVE!${_NC}"
|
|
|
|
echo "waiting before build(10)"
|
|
|
|
sleep 10
|
|
|
|
|
|
|
|
|
|
|
|
npm run build
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo -e "${_RED}SUCCESS${_NC}"
|
|
|
|
mkdir -p /status/success
|
|
|
|
touch /status/success/build
|
|
|
|
else
|
|
|
|
echo -e "${_RED}FAIL${_NC}"
|
|
|
|
mkdir -p /status/fail
|
|
|
|
touch /status/fail/build
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "${_RED}!SEE RESULT ABOVE!${_NC}"
|
|
|
|
echo "waiting before archiving(10)"
|
|
|
|
sleep 10
|
|
|
|
apk add zip
|
2024-01-01 01:14:38 +03:00
|
|
|
if [[ -f "/link/maketrandevu-$MAKETRANDEVU_VER.zip" ]]; then
|
2023-12-22 23:44:48 +03:00
|
|
|
echo "THIS VERSION ALREADY EXIST"
|
|
|
|
sleep 1
|
|
|
|
echo -e "${_RED}DELETING OLD ARCHIVE${_NC} (after waiting 10 sec)"
|
|
|
|
sleep 10
|
2024-01-01 01:14:38 +03:00
|
|
|
rm "/link/maketrandevu-$MAKETRANDEVU_VER.zip"
|
2023-12-22 23:44:48 +03:00
|
|
|
fi
|
|
|
|
|
2024-01-01 01:14:38 +03:00
|
|
|
cd /docker_build/maketrandevu/build/ || exit
|
|
|
|
zip -r "/link/maketrandevu-$MAKETRANDEVU_VER.zip" ./*
|
2023-12-22 23:44:48 +03:00
|
|
|
sleep 5
|
|
|
|
echo "BYE!"
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "EXIT"
|
|
|
|
|
|
|
|
# TODO convert to dockerfile
|