From 8301e6435902f2df577aa3a4664f63731e24c85d Mon Sep 17 00:00:00 2001 From: Thiago Lagden Date: Tue, 9 Nov 2021 13:06:32 -0300 Subject: [PATCH] remove unused scripts --- bin/docker/deploy | 77 ------------------------------------------ bin/docker/image | 73 ---------------------------------------- bin/docker/start | 68 ------------------------------------- bin/docker/stop | 29 ---------------- bin/docker/test | 85 ----------------------------------------------- bin/docker/watch | 22 ------------ bin/local/start | 62 ---------------------------------- bin/local/test | 51 ---------------------------- 8 files changed, 467 deletions(-) delete mode 100755 bin/docker/deploy delete mode 100755 bin/docker/image delete mode 100755 bin/docker/start delete mode 100755 bin/docker/stop delete mode 100755 bin/docker/test delete mode 100755 bin/docker/watch delete mode 100755 bin/local/start delete mode 100755 bin/local/test diff --git a/bin/docker/deploy b/bin/docker/deploy deleted file mode 100755 index 2c01354..0000000 --- a/bin/docker/deploy +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash - -DIR="$(cd $(dirname $0) && pwd)" -BIN_DIR="$(cd $DIR/.. && pwd)" - -# Import functions -. $BIN_DIR/helper/fn - -usage() { - cat <<-EOF - - Usage: $0 [options...] - - Options: - -i Ignore build image - -e Environment - -h Show usage - -EOF -exit 0 -} - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -BUILD=1 -OPT="staging" - -while getopts "ie:h" o -do - case ${o} in - i) BUILD=0 ;; - e) test $OPTARG = "staging" -o $OPTARG = "production" && OPT=$OPTARG || usage ;; - h) usage ;; - \?) usage ;; - esac -done - -# ENV File -load_env $OPT - -if test -z "${DEPLOY_FOLDER}"; then - abort "Missing DEPLOY_FOLDER" -fi - -# BUILD IMAGE and PUSH -if test "${BUILD}" = "1"; then - $BIN_DIR/docker/image -e $OPT - test $? -ne 0 && abort "Image build fail" || ok "Image build done" -fi - -# ENVSUBST -ENVSUBST_FILE="$(which envsubst)" -if test ! -f "${ENVSUBST_FILE}"; then - abort "Missing envsubst" -fi - -# Criando docker-compose -COMPOSE_TEMPLATE="${CURR_FOLDER}/docker-compose.template.yml" -COMPOSE_DEPLOY="${CURR_FOLDER}/docker-compose-${VERSION}.yml" -envsubst < $COMPOSE_TEMPLATE > $COMPOSE_DEPLOY - -# Sync -rsync -avzlh --rsync-path="mkdir -p ${DEPLOY_FOLDER}; /usr/bin/rsync" -e ssh -r --delete --include-from "${CURR_FOLDER}/.rsync-include" --exclude-from "${CURR_FOLDER}/.rsync-exclude" "${CURR_FOLDER}/." "${USER}@${SERVER}:${DEPLOY_FOLDER}" > "${CURR_FOLDER}/.rsync.log" -test $? -ne 0 && abort "Rsync fail" || ok "Rsync done" - -# Run -ssh -T $USER@$SERVER < Environment - -h Show usage - -EOF -exit 0 -} - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -OPT="staging" - -while getopts "e:h" o -do - case ${o} in - e) [ $OPTARG = "staging" -o $OPTARG = "production" ] && OPT=$OPTARG || usage ;; - h) usage ;; - \?) usage ;; - esac -done - -# ENV File -load_env $OPT - -# Generate ENVs for frontend application -if test "${REQUIRE_GEN:-0}" = "1"; then - gen_env "${CURR_FOLDER}/resource/env.js" -fi - -# Variables -REGISTRY_USER="$(cat ${CURR_FOLDER}/.registry-user)" -REGISTRY_PASSWD="$(cat ${CURR_FOLDER}/.registry-passwd)" -TAG_IMAGE="${REGISTRY}/${IMAGE}:${VERSION}" -TAG_IMAGE_LATEST="${REGISTRY}/${IMAGE}:latest" - -# Build -docker build \ - --build-arg NODE_ENV=${NODE_ENV} \ - --target main \ - --compress \ - --force-rm \ - --no-cache . \ - --tag $TAG_IMAGE \ - --tag $TAG_IMAGE_LATEST - -test $? -ne 0 && abort "Falha no build da image --> ${TAG_IMAGE}" || ok "Build image ok --> ${TAG_IMAGE}" - -# Push (Send image to Registry) -cat ${CURR_FOLDER}/.registry-passwd | docker login $REGISTRY --username $REGISTRY_USER --password-stdin -docker push $TAG_IMAGE -docker push $TAG_IMAGE_LATEST - -# # Cleanup -# docker rmi $(docker images -q -f "dangling=true" -f "label=autodelete=true") - -ok "Build finalizado... Yeahh!!!" - -exit 0 diff --git a/bin/docker/start b/bin/docker/start deleted file mode 100755 index e7f5358..0000000 --- a/bin/docker/start +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -DIR="$(cd $(dirname $0) && pwd)" -BIN_DIR="$(cd $DIR/.. && pwd)" - -# Import functions -. $BIN_DIR/helper/fn - -usage() { - cat <<-EOF - - Usage: $0 [options...] - - Options: - -b Build image - -d Run containers in the background - -s Docker compose service name - -h Show usage - -EOF -exit 0 -} - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -BUILD="" -SERVICE="" -DAEMON="--abort-on-container-exit" -OPT="development" -COMPOSE_TEMPLATE="${CURR_FOLDER}/docker-compose.template.yml" -COMPOSE_LOCAL="${CURR_FOLDER}/docker-compose.local.yml" - -while getopts "bds:h" o -do - case ${o} in - b) BUILD="--build" ;; - d) DAEMON="-d" ;; - s) SERVICE=$OPTARG ;; - h) usage ;; - \?) usage ;; - esac -done - -# ENV File -load_env $OPT - -# Generate ENVs for frontend application -if test "${REQUIRE_GEN:-0}" = "1"; then - gen_env "${CURR_FOLDER}/resource/env.js" -fi - -docker compose \ - -f $COMPOSE_TEMPLATE \ - -f $COMPOSE_LOCAL \ - up \ - --force-recreate \ - --always-recreate-deps \ - --remove-orphans \ - --renew-anon-volumes \ - $BUILD \ - $DAEMON \ - $SERVICE - -test $? -ne 0 && abort "Docker Compose up failed" || ok "Stopped gracefully" - -exit 0 diff --git a/bin/docker/stop b/bin/docker/stop deleted file mode 100755 index 2041993..0000000 --- a/bin/docker/stop +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -DIR="$(cd $(dirname $0) && pwd)" -BIN_DIR="$(cd $DIR/.. && pwd)" - -# Import functions -. $BIN_DIR/helper/fn - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -OPT="development" -COMPOSE_TEMPLATE="${CURR_FOLDER}/docker-compose.template.yml" -COMPOSE_LOCAL="${CURR_FOLDER}/docker-compose.local.yml" - -# ENV File -load_env $OPT - -docker compose \ - -f $COMPOSE_TEMPLATE \ - -f $COMPOSE_LOCAL \ - down \ - --volumes \ - --remove-orphans - -test $? -ne 0 && abort "Docker Compose down failed" || ok "Stopped" - -exit 0 diff --git a/bin/docker/test b/bin/docker/test deleted file mode 100755 index ccfcd3e..0000000 --- a/bin/docker/test +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -DIR="$(cd $(dirname $0) && pwd)" -BIN_DIR="$(cd $DIR/.. && pwd)" - -# Import functions -. $BIN_DIR/helper/fn - -usage() { - cat <<-EOF - - Usage: $0 [options...] - - Options: - -b Build image - -s Docker compose service name - -h Show usage - -EOF -exit 0 -} - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -BUILD="" -SERVICE="app" -OPT="test" -COMPOSE_TEMPLATE="${CURR_FOLDER}/docker-compose.template.yml" -COMPOSE_LOCAL="${CURR_FOLDER}/docker-compose.local.yml" -COMPOSE_TEST="${CURR_FOLDER}/docker-compose.test.yml" - -_cleanup() { - docker compose \ - -f $COMPOSE_TEMPLATE \ - -f $COMPOSE_LOCAL \ - -f $COMPOSE_TEST \ - down \ - --volumes \ - --remove-orphans > /dev/null 2>&1 -} - -trap '_cleanup; abort "Tests failed for unexpected reasons"' HUP INT QUIT PIPE TERM SIGINT SIGTERM - -while getopts "bs:h" o -do - case ${o} in - b) BUILD="--build" ;; - s) SERVICE=$OPTARG ;; - h) usage ;; - \?) usage ;; - esac -done - -# ENV File -load_env $OPT - -# Generate ENVs for frontend application -if test "${REQUIRE_GEN:-0}" = "1"; then - gen_env "${CURR_FOLDER}/resource/env.js" -fi - -docker compose \ - -f $COMPOSE_TEMPLATE \ - -f $COMPOSE_LOCAL \ - -f $COMPOSE_TEST \ - up \ - --force-recreate \ - --always-recreate-deps \ - --abort-on-container-exit \ - --exit-code-from ${SERVICE} \ - --remove-orphans \ - --renew-anon-volumes \ - $BUILD - -if test $? -ne 0; then - _cleanup - abort "Test FAIL" -fi - -_cleanup -ok "Test PASS" - -exit 0 diff --git a/bin/docker/watch b/bin/docker/watch deleted file mode 100755 index 2e3d7e9..0000000 --- a/bin/docker/watch +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -DIR="$(cd $(dirname $0) && pwd)" -BIN_DIR="$(cd $DIR/.. && pwd)" - -# Import functions -. $BIN_DIR/helper/fn - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -ok "Running cmd: ${WATCH_CMD}" - -# Watch command -eval ${WATCH_CMD} - -if test $? -ne 0; then - abort "Watch failed" -fi - -exit 0 diff --git a/bin/local/start b/bin/local/start deleted file mode 100755 index 312932b..0000000 --- a/bin/local/start +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -DIR="$(cd $(dirname $0) && pwd)" -BIN_DIR="$(cd $DIR/.. && pwd)" - -# Import functions -. $BIN_DIR/helper/fn - -# Usage -usage() { - cat <<-EOF - - Usage: $0 [-w] - - Options: - -w Watch and reload application - -h Show usage - -EOF -exit 2 -} - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -OPT="development" - -unset WATCH -WATCH=false - -while getopts "uh" o -do - case ${o} in - w) WATCH=true ;; - h) usage ;; - \?) usage ;; - esac -done - -# ENV File -load_env $OPT - -# Generate ENVs for frontend application -if test "${REQUIRE_GEN:-0}" = "1"; then - gen_env "${CURR_FOLDER}/resource/env.js" -fi - -if $WATCH; then - ok "Running cmd: ${WATCH_LOCAL_CMD}" - - # Watch command - eval ${WATCH_LOCAL_CMD} - - if test $? -ne 0; then - abort "Watch failed" - fi -else - $START_CMD -fi - -exit 0 diff --git a/bin/local/test b/bin/local/test deleted file mode 100755 index 370eacb..0000000 --- a/bin/local/test +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -DIR="$(cd $(dirname $0) && pwd)" -BIN_DIR="$(cd $DIR/.. && pwd)" - -# Import functions -. $BIN_DIR/helper/fn - -usage() { - cat <<-EOF - - Usage: $0 [options...] - - Options: - -u Update snapshot - -h Show usage - -EOF -exit 0 -} - -# Go to current directory -CURR_FOLDER="$(pwd)" -cd $CURR_FOLDER - -unset UPDATE_SNAPSHOT -UPDATE_SNAPSHOT="" - -OPT="test" - -while getopts "uh" o -do - case ${o} in - u) UPDATE_SNAPSHOT="-- -u" ;; - h) usage ;; - \?) usage ;; - esac -done - -# ENV File -load_env $OPT - -# Generate ENVs for frontend application -if test "${REQUIRE_GEN:-0}" = "1"; then - gen_env "${CURR_FOLDER}/resource/env.js" -fi - -CMD="${TEST_CMD} ${UPDATE_SNAPSHOT}" -$CMD - -exit 0