Signed-off-by: Zoey <zoey@z0ey.de>
This commit is contained in:
Zoey
2022-12-16 09:05:58 +01:00
parent fd30cfe98b
commit 19a304d9ce
169 changed files with 2074 additions and 27536 deletions

View File

@@ -1,17 +0,0 @@
#!/bin/bash
# Colors
BLUE='\E[1;34m'
CYAN='\E[1;36m'
GREEN='\E[1;32m'
RED='\E[1;31m'
RESET='\E[0m'
YELLOW='\E[1;33m'
export BLUE CYAN GREEN RED RESET YELLOW
# Docker Compose
COMPOSE_PROJECT_NAME="npmdev"
COMPOSE_FILE="docker/docker-compose.dev.yml"
export COMPOSE_FILE COMPOSE_PROJECT_NAME

View File

@@ -1,36 +0,0 @@
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
echo -e "${BLUE} ${CYAN}Building docker multiarch: ${YELLOW}${*}${RESET}"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${DIR}/.." || exit 1
# determine commit if not already set
if [ "$BUILD_COMMIT" == "" ]; then
BUILD_COMMIT=$(git log -n 1 --format=%h)
fi
# Buildx Builder
docker buildx create --name "${BUILDX_NAME:-npm}" || echo
docker buildx use "${BUILDX_NAME:-npm}"
docker buildx build \
--build-arg BUILD_VERSION="${BUILD_VERSION:-dev}" \
--build-arg BUILD_COMMIT="${BUILD_COMMIT:-notset}" \
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \
--build-arg GOPROXY="${GOPROXY:-}" \
--build-arg GOPRIVATE="${GOPRIVATE:-}" \
--platform linux/amd64,linux/arm64,linux/arm/7 \
--progress plain \
--pull \
-f docker/Dockerfile \
$@ \
.
rc=$?
docker buildx rm "${BUILDX_NAME:-npm}"
echo -e "${BLUE} ${GREEN}Multiarch build Complete${RESET}"
exit $rc

View File

@@ -1,14 +0,0 @@
#!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
# Ensure docker-compose exists
# Make sure docker exists
if hash docker-compose 2>/dev/null; then
cd "${DIR}/.."
echo -e "${BLUE} ${CYAN}Destroying Dev Stack ...${RESET}"
docker-compose down --remove-orphans --volumes
else
echo -e "${RED} docker-compose command is not available${RESET}"
fi

View File

@@ -1,14 +0,0 @@
#!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
# Ensure docker-compose exists
if hash docker 2>/dev/null; then
cd "${DIR}/.."
echo -e "${BLUE} ${CYAN}Building Docs ...${RESET}"
docker run --rm -e CI=true -v "$(pwd)/docs:/app/docs" -w /app/docs node:alpine sh -c "yarn install && yarn build && chown -R $(id -u):$(id -g) /app/docs"
echo -e "${BLUE} ${GREEN}Building Docs Complete${RESET}"
else
echo -e "${RED} docker command is not available${RESET}"
fi

View File

@@ -1,52 +0,0 @@
#!/bin/bash
# Note: This script is designed to be run inside CI builds
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
echo -e "${BLUE} ${CYAN}Uploading docs in: ${YELLOW}$1${RESET}"
cd "$1" || exit 1
ALL_FILES=$(find . -follow)
for FILE in $ALL_FILES
do
# remove preceding ./
FILE=$(echo "$FILE" | sed -E "s/\.\///g")
echo '======================================='
echo "FILE: $FILE"
if [[ -d $FILE ]]; then
echo "Skipping $FILE because it's a directory"
elif [[ -f $FILE ]]; then
PARAM_STRING="--guess-mime-type"
EXT="${FILE##*.}"
if [ "$EXT" == "css" ]; then
PARAM_STRING="-mtext/css"
elif [ "$EXT" == "js" ]; then
PARAM_STRING="-mapplication/javascript"
elif [[ "$EXT" == "html" ]]; then
PARAM_STRING="-mtext/html"
elif [[ "$EXT" == "png" ]]; then
PARAM_STRING="-mimage/png"
elif [[ "$EXT" == "jpg" ]]; then
PARAM_STRING="-mimage/jpg"
elif [[ "$EXT" == "svg" ]]; then
PARAM_STRING="-mimage/svg+xml"
fi
DEST_FOLDER=$(dirname "$FILE")
if [ "$DEST_FOLDER" == "." ]; then
DEST_FOLDER=
else
DEST_FOLDER="${DEST_FOLDER}/"
fi
echo s3cmd -v -f -P "$PARAM_STRING" --add-header="Cache-Control:public,max-age=604800" sync "$FILE" "s3://$S3_BUCKET/$DEST_FOLDER"
s3cmd -v -f -P "$PARAM_STRING" --add-header="Cache-Control:public,max-age=604800" sync "$FILE" "s3://$S3_BUCKET/$DEST_FOLDER"
rc=$?; if [ $rc != 0 ]; then exit $rc; fi
fi
done
echo -e "${BLUE} ${GREEN}Upload Complete${RESET}"

View File

@@ -1,17 +0,0 @@
#!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
DOCKER_IMAGE=nginxproxymanager/nginx-full:certbot-node
# Ensure docker exists
if hash docker 2>/dev/null; then
docker pull "${DOCKER_IMAGE}"
cd "${DIR}/.."
echo -e "${BLUE} ${CYAN}Building Frontend ...${RESET}"
docker run --rm -e CI=true -v "$(pwd)/frontend:/app/frontend" -v "$(pwd)/global:/app/global" -w /app/frontend "$DOCKER_IMAGE" sh -c "yarn install && yarn build && yarn build && chown -R $(id -u):$(id -g) /app/frontend"
echo -e "${BLUE} ${GREEN}Building Frontend Complete${RESET}"
else
echo -e "${RED} docker command is not available${RESET}"
fi

View File

@@ -1,34 +0,0 @@
#!/bin/bash -e
# Note: This script is designed to be run inside a Docker Build for a container
CYAN='\E[1;36m'
YELLOW='\E[1;33m'
BLUE='\E[1;34m'
GREEN='\E[1;32m'
RESET='\E[0m'
S6_OVERLAY_VERSION=1.22.1.0
TARGETPLATFORM=$1
# Determine the correct binary file for the architecture given
case $TARGETPLATFORM in
linux/arm64)
S6_ARCH=aarch64
;;
linux/arm/v7)
S6_ARCH=armhf
;;
*)
S6_ARCH=amd64
;;
esac
echo -e "${BLUE} ${CYAN}Installing S6-overlay v${S6_OVERLAY_VERSION} for ${YELLOW}${TARGETPLATFORM} (${S6_ARCH})${RESET}"
curl -L -o "/tmp/s6-overlay-${S6_ARCH}.tar.gz" "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.gz" \
&& tar -xzf "/tmp/s6-overlay-${S6_ARCH}.tar.gz" -C /
echo -e "${BLUE} ${GREEN}S6-overlay install Complete${RESET}"

View File

@@ -1,28 +0,0 @@
#!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
# Ensure docker-compose exists
if hash docker-compose 2>/dev/null; then
cd "${DIR}/.."
echo -e "${BLUE} ${CYAN}Starting Dev Stack ...${RESET}"
docker-compose up -d --remove-orphans --force-recreate --build
echo ""
echo -e "${CYAN}Admin UI: http://127.0.0.1:3081${RESET}"
echo -e "${CYAN}Nginx: http://127.0.0.1:3080${RESET}"
echo -e "${CYAN}Swagger Doc: http://127.0.0.1:3001${RESET}"
echo ""
if [ "$1" == "-f" ]; then
echo -e "${BLUE} ${YELLOW}Following Backend Container:${RESET}"
docker logs -f npm_core
else
echo -e "${YELLOW}Hint:${RESET} You can follow the output of some of the containers with:"
echo " docker logs -f npm_core"
fi
else
echo -e "${RED} docker-compose command is not available${RESET}"
fi

View File

@@ -1,14 +0,0 @@
#!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
# Ensure docker-compose exists
# Make sure docker exists
if hash docker-compose 2>/dev/null; then
cd "${DIR}/.."
echo -e "${BLUE} ${CYAN}Stopping Dev Stack ...${RESET}"
docker-compose down --remove-orphans
else
echo -e "${RED} docker-compose command is not available${RESET}"
fi

View File

@@ -1,13 +0,0 @@
#!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
# Ensure docker-compose exists
if hash docker-compose 2>/dev/null; then
cd "${DIR}/.."
echo -e "${BLUE} ${CYAN}Testing Dev Stack ...${RESET}"
docker-compose exec -T npm bash -c "cd /app && task test"
else
echo -e "${RED} docker-compose command is not available${RESET}"
fi

View File

@@ -1,34 +0,0 @@
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh"
if [ "$1" == "" ]; then
echo "Waits for a docker container to be healthy."
echo "Usage: $0 docker-container"
exit 1
fi
SERVICE=$1
LOOPCOUNT=0
HEALTHY=
LIMIT=${2:-90}
echo -e "${BLUE} ${CYAN}Waiting for healthy: ${YELLOW}${SERVICE}${RESET}"
until [ "${HEALTHY}" = "healthy" ]; do
echo -n "."
sleep 1
HEALTHY="$(docker inspect -f '{{.State.Health.Status}}' $SERVICE)"
((LOOPCOUNT++))
if [ "$LOOPCOUNT" == "$LIMIT" ]; then
echo ""
echo ""
echo -e "${BLUE} ${RED}Timed out waiting for healthy${RESET}"
exit 1
fi
done
echo ""
echo -e "${BLUE} ${GREEN}Healthy!${RESET}"