2023-12-20 18:06:50 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-12-20 20:20:57 +03:00
|
|
|
# Docker commands to build iflrandevu
|
|
|
|
# First setup docker and install alpine image
|
2023-12-20 18:06:50 +03:00
|
|
|
# Approximately 10min (tested with 4vcpu / 8GB RAM / 30Mbps network speed)
|
2023-12-20 20:20:57 +03:00
|
|
|
|
2023-12-20 21:40:49 +03:00
|
|
|
# IFLRANDEVU_VER="test"
|
2023-12-20 20:20:57 +03:00
|
|
|
IFLRANDEVU_VER="1.4.3-ifl.2" # UPDATE MANUALLY !
|
|
|
|
|
|
|
|
_RED='\033[0;31m'
|
|
|
|
_NC='\033[0m \e[0m' # No Color, No Effect
|
|
|
|
if [[ $1 != "docker" ]]; then
|
|
|
|
if [[ $(pwd) != *iflrandevu/docker/build ]]; then
|
|
|
|
echo "PLEASE CHANGE DIRECTORY TO \`iflrandevu/docker/build\` BEFORE STARTING SCRIPT"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
docker rm IFLRANDEVU_BUILDER
|
2023-12-20 21:40:49 +03:00
|
|
|
echo "removed"
|
2023-12-20 20:20:57 +03:00
|
|
|
docker run -it -d --name IFLRANDEVU_BUILDER --mount type=bind,source=".",target=/link/ alpine:latest "/bin/sh"
|
|
|
|
echo -e "RUN COMMANDS IN ALPINE DOCKER"
|
|
|
|
echo -e "RUN SCRIPT: \`${_RED}apk add bash && bash /link/docker.sh docker${_NC}\`"
|
|
|
|
docker attach IFLRANDEVU_BUILDER --detach-keys="ctrl-k"
|
2023-12-20 20:30:19 +03:00
|
|
|
echo "EXIT"
|
2023-12-20 18:06:50 +03:00
|
|
|
exit
|
2023-12-20 20:20:57 +03:00
|
|
|
elif [[ $1 == "docker" ]]; then
|
2023-12-20 21:40:49 +03:00
|
|
|
set -x
|
2023-12-20 20:20:57 +03:00
|
|
|
# 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/
|
|
|
|
cd /docker_build/
|
|
|
|
git clone https://git.aliberksandikci.com.tr/ifl/iflrandevu
|
|
|
|
cd iflrandevu
|
2023-12-20 18:06:50 +03:00
|
|
|
|
2023-12-20 20:20:57 +03:00
|
|
|
composer update
|
|
|
|
composer upgrade
|
|
|
|
npm audit fix # maybe no need ?
|
2023-12-20 21:40:49 +03:00
|
|
|
npm install
|
|
|
|
if [ $? -eq 0 ]; then
|
2023-12-20 21:56:46 +03:00
|
|
|
echo -e "${_RED}SUCCESS${_NC}"
|
2023-12-20 21:40:49 +03:00
|
|
|
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
|
2023-12-20 21:56:46 +03:00
|
|
|
echo -e "${_RED}SUCCESS${_NC}"
|
2023-12-20 21:40:49 +03:00
|
|
|
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
|
2023-12-20 21:56:46 +03:00
|
|
|
|
|
|
|
|
2023-12-20 20:20:57 +03:00
|
|
|
npm run build
|
2023-12-20 21:56:46 +03:00
|
|
|
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
|
|
|
|
|
2023-12-20 20:20:57 +03:00
|
|
|
|
2023-12-20 20:30:19 +03:00
|
|
|
echo -e "${_RED}!SEE RESULT ABOVE!${_NC}"
|
2023-12-20 21:40:49 +03:00
|
|
|
echo "waiting before archiving(10)"
|
2023-12-20 20:30:19 +03:00
|
|
|
sleep 10
|
2023-12-20 20:20:57 +03:00
|
|
|
apk add zip
|
|
|
|
if [[ -f "/link/iflrandevu-$IFLRANDEVU_VER.zip" ]]; then
|
|
|
|
echo "THIS VERSION ALREADY EXIST"
|
|
|
|
sleep 1
|
2023-12-20 20:22:36 +03:00
|
|
|
echo -e "${_RED}DELETING OLD ARCHIVE${_NC} (after waiting 10 sec)"
|
|
|
|
sleep 10
|
2023-12-20 20:20:57 +03:00
|
|
|
rm "/link/iflrandevu-$IFLRANDEVU_VER.zip"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd /docker_build/iflrandevu/build/
|
|
|
|
zip -r "/link/iflrandevu-$IFLRANDEVU_VER.zip" ./*
|
|
|
|
sleep 5
|
|
|
|
echo "BYE!"
|
2023-12-20 18:06:50 +03:00
|
|
|
exit
|
2023-12-20 20:20:57 +03:00
|
|
|
|
2023-12-20 18:06:50 +03:00
|
|
|
fi
|
|
|
|
|
2023-12-20 20:20:57 +03:00
|
|
|
echo "EXIT"
|
|
|
|
|
|
|
|
# TODO convert to dockerfile
|