iflrandevu/docker/build/docker.sh
2023-12-20 21:56:46 +03:00

103 lines
2.8 KiB
Bash
Executable file

#!/bin/bash
# Docker commands to build iflrandevu
# First setup docker and install alpine image
# Approximately 10min (tested with 4vcpu / 8GB RAM / 30Mbps network speed)
# IFLRANDEVU_VER="test"
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
echo "removed"
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"
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/
cd /docker_build/
git clone https://git.aliberksandikci.com.tr/ifl/iflrandevu
cd iflrandevu
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
if [[ -f "/link/iflrandevu-$IFLRANDEVU_VER.zip" ]]; then
echo "THIS VERSION ALREADY EXIST"
sleep 1
echo -e "${_RED}DELETING OLD ARCHIVE${_NC} (after waiting 10 sec)"
sleep 10
rm "/link/iflrandevu-$IFLRANDEVU_VER.zip"
fi
cd /docker_build/iflrandevu/build/
zip -r "/link/iflrandevu-$IFLRANDEVU_VER.zip" ./*
sleep 5
echo "BYE!"
exit
fi
echo "EXIT"
# TODO convert to dockerfile