#!/bin/bash # Docker commands to build maketrandevu # First setup docker and install alpine image # Approximately 10min (tested with 4vcpu / 8GB RAM / 30Mbps network speed) # MAKETRANDEVU_VER="test" MAKETRANDEVU_VER="1.5.0-RC2" # UPDATE MANUALLY ! _RED='\033[0;31m' _NC='\033[0m \e[0m' # No Color, No Effect if [[ $1 != "docker" ]]; then if [[ $(pwd) != *maketrandevu/docker/build ]]; then echo "PLEASE CHANGE DIRECTORY TO \`maketrandevu/docker/build\` BEFORE STARTING SCRIPT" exit fi docker rm MAKETRANDEVU_BUILDER echo "removed" docker run -it -d --name MAKETRANDEVU_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 MAKETRANDEVU_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/ || exit git clone https://git.aliberksandikci.com.tr/maket/maketrandevu cd maketrandevu || exit 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/maketrandevu-$MAKETRANDEVU_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/maketrandevu-$MAKETRANDEVU_VER.zip" fi cd /docker_build/maketrandevu/build/ || exit zip -r "/link/maketrandevu-$MAKETRANDEVU_VER.zip" ./* sleep 5 echo "BYE!" exit fi echo "EXIT" # TODO convert to dockerfile