From 2bc1fe0d3432af1e81ac18fa94b7576d3bd8a322 Mon Sep 17 00:00:00 2001 From: asandikci Date: Wed, 20 Dec 2023 20:20:57 +0300 Subject: [PATCH] test: update build files --- .gitignore | 2 +- docker/build/docker.sh | 93 +++++++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 524016c8..d830e1de 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ /docs/jsdoc/html /docs/plato/html /docker/mysql/* -/docker/build/output/* +/docker/build/iflrandevu-* !/docker/mysql/.gitkeep /node_modules/ /npm-debug.log diff --git a/docker/build/docker.sh b/docker/build/docker.sh index ce3e846e..8138ca0e 100755 --- a/docker/build/docker.sh +++ b/docker/build/docker.sh @@ -1,46 +1,63 @@ #!/bin/bash +# Docker commands to build iflrandevu +# First setup docker and install alpine image # Approximately 10min (tested with 4vcpu / 8GB RAM / 30Mbps network speed) -# Docker commands (will be converted to dockerfile) -if [[ $(pwd) != *iflrandevu/docker/build ]]; then - echo "PLEASE CHANGE DIRECTORY TO \`iflrandevu/docker/build\` BEFORE STARTING SCRIPT" - exit -fi -docker rm IFLRANDEVU_BUILDER -docker run -it -d --name IFLRANDEVU_BUILDER --mount type=bind,source=".",target=/link/ alpine:latest "/bin/sh" -docker attach IFLRANDEVU_BUILDER --detach-keys="ctrl-k" -if [[ 1 -eq 1 ]]; then - echo "RUN COMMANDS IN ALPINE DOCKER" +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 + 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" exit +elif [[ $1 == "docker" ]]; then + set -ex + # 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 && composer install + npm run build + + apk add zip + echo "DELETING OLD BUILD FILE!!! (after waiting 30 sec)" + sleep 30 + mkdir -p /link/output/ + if [[ -f "/link/iflrandevu-$IFLRANDEVU_VER.zip" ]]; then + echo "THIS VERSION ALREADY EXIST" + sleep 1 + echo "DELETING OLD ARCHIVE" + sleep 5 + 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 -# Inside Alpine Docker -apk update && apk upgrade -apk add git npm composer -apk add php-gd php-dom php-xml php-xmlwriter phpunit +echo "EXIT" -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 && composer install -npm run build - -apk add zip -echo "DELETING OLD BUILD FILE!!! (after waiting 30 sec)" -sleep 30 -mkdir -p /link/output/ -rm /link/output/IFLRANDEVU_BUILD_OUTPUT_LATEST.zip -cd /docker_build/iflrandevu/build/ -zip -r /link/output/IFLRANDEVU_BUILD_OUTPUT_LATEST.zip ./* -sleep 5 -echo "BYE!" -exit - -# TODO run itself -# TODO dockerfile +# TODO convert to dockerfile