Moved v3 code from NginxProxyManager/nginx-proxy-manager-3 to NginxProxyManager/nginx-proxy-manager
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
#!/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'
|
||||
BLUE='\033[1;34m'
|
||||
CYAN='\033[1;36m'
|
||||
GREEN='\033[1;32m'
|
||||
RED='\033[1;31m'
|
||||
RESET='\033[0m'
|
||||
YELLOW='\033[1;33m'
|
||||
|
||||
export BLUE CYAN GREEN RED RESET YELLOW
|
||||
|
||||
|
@ -5,7 +5,6 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
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
|
||||
@ -18,11 +17,14 @@ 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 BUILD_VERSION="${BUILD_VERSION:-dev}" \
|
||||
--build-arg NOW="$(date --rfc-3339=s)" \
|
||||
--build-arg SKIP_TESTS=1 \
|
||||
--build-arg GOPRIVATE="${GOPRIVATE:-}" \
|
||||
--build-arg GOPROXY="${GOPROXY:-}" \
|
||||
--build-arg SENTRY_DSN="${SENTRY_DSN:-}" \
|
||||
--platform linux/amd64,linux/arm64,linux/arm/7 \
|
||||
--progress plain \
|
||||
--pull \
|
||||
|
77
scripts/ci/build-backend
Executable file
77
scripts/ci/build-backend
Executable file
@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
IMAGE=jc21/gotools:latest
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
. "$DIR/../.common.sh"
|
||||
|
||||
BUILD_DATE=$(date '+%Y-%m-%d %T %Z')
|
||||
NOW=$(date --rfc-3339=s)
|
||||
|
||||
cd $DIR/../..
|
||||
|
||||
if [ "$BUILD_COMMIT" = "" ]; then
|
||||
BUILD_COMMIT=$(git log -n 1 --format=%h)
|
||||
fi
|
||||
|
||||
if [ "$BUILD_VERSION" = "" ]; then
|
||||
BUILD_VERSION=$(cat .version)
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}❯ ${GREEN}build-backend:${RESET}"
|
||||
echo " BUILD_COMMIT: $BUILD_COMMIT"
|
||||
echo " BUILD_DATE: $BUILD_DATE"
|
||||
echo " BUILD_VERSION: $BUILD_VERSION"
|
||||
echo " CGO_ENABLED: ${CGO_ENABLED:-}"
|
||||
echo " GO111MODULE: ${GO111MODULE:-}"
|
||||
echo " GOPRIVATE: ${GOPRIVATE:-}"
|
||||
echo " GOPROXY: ${GOPROXY:-}"
|
||||
echo " NOW: $NOW"
|
||||
|
||||
cleanup() {
|
||||
docker run --rm -v "$(pwd):/app" "${IMAGE}" chown -R "$(id -u):$(id -g)" /app/bin
|
||||
}
|
||||
|
||||
build_backend() {
|
||||
echo -e "${BLUE}❯ ${CYAN}Building backend for ${YELLOW}${1}-${2} ...${RESET}"
|
||||
|
||||
FILENAME="nginxproxymanager-${1}_${2}"
|
||||
if [ "$1" = "windows" ]; then
|
||||
FILENAME="${FILENAME}.exe"
|
||||
fi
|
||||
|
||||
docker run --rm \
|
||||
-e BUILD_COMMIT="${BUILD_COMMIT:-notset}" \
|
||||
-e BUILD_DATE="$BUILD_DATE" \
|
||||
-e GOARCH="${2}" \
|
||||
-e GOOS="${1}" \
|
||||
-e GOPRIVATE="${GOPRIVATE:-}" \
|
||||
-e GOPROXY="${GOPROXY:-}" \
|
||||
-e NOW="$NOW" \
|
||||
-e TZ="${TZ:-Australia/Brisbane}" \
|
||||
-v "$(pwd):/app" \
|
||||
-w '/app/backend' \
|
||||
"${IMAGE}" \
|
||||
go build \
|
||||
-ldflags "-w -s -X main.commit=${BUILD_COMMIT:-notset} -X main.version=${BUILD_VERSION} -X main.sentryDSN=${SENTRY_DSN:-}" \
|
||||
-o "/app/bin/$FILENAME" \
|
||||
./cmd/server
|
||||
}
|
||||
|
||||
docker pull "${IMAGE}"
|
||||
|
||||
build_backend "darwin" "amd64"
|
||||
build_backend "darwin" "arm64"
|
||||
build_backend "linux" "amd64"
|
||||
build_backend "linux" "arm64"
|
||||
build_backend "linux" "arm"
|
||||
build_backend "openbsd" "amd64"
|
||||
build_backend "windows" "amd64"
|
||||
|
||||
cleanup
|
||||
|
||||
echo -e "${BLUE}❯ ${GREEN}build-backend completed${RESET}"
|
||||
exit 0
|
||||
|
||||
trap cleanup EXIT
|
19
scripts/ci/build-cleanup
Executable file
19
scripts/ci/build-cleanup
Executable file
@ -0,0 +1,19 @@
|
||||
#!/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}Build Cleanup ...${RESET}"
|
||||
|
||||
docker run --rm -e CI=true -v "$(pwd):/app" -w /app jc21/gotools:latest rm -rf \
|
||||
/app/frontend/node_modules \
|
||||
/app/docs/node_modules \
|
||||
/app/docs/.vuepress/dist
|
||||
|
||||
echo -e "${BLUE}❯ ${GREEN}Build Cleanup Complete${RESET}"
|
||||
else
|
||||
echo -e "${RED}❯ docker command is not available${RESET}"
|
||||
fi
|
49
scripts/ci/build-frontend
Executable file
49
scripts/ci/build-frontend
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BACKEND_ASSETS=backend/embed/assets
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
. "$DIR/../.common.sh"
|
||||
|
||||
docker_cmd() {
|
||||
docker run --rm \
|
||||
-e CI=true \
|
||||
-e REACT_APP_VERSION=${BUILD_VERSION:-0.0.0} \
|
||||
-e REACT_APP_COMMIT=${BUILD_COMMIT:-0000000} \
|
||||
-v "$(pwd):/app" \
|
||||
-w "/app/frontend" \
|
||||
node:14 \
|
||||
${*}
|
||||
}
|
||||
|
||||
cd "${DIR}/../.." || exit 1
|
||||
echo -e "${BLUE}❯ ${CYAN}Installing Frontend deps ...${RESET}"
|
||||
rm -rf frontend/node_modules
|
||||
docker_cmd yarn install
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Checking locales ...${RESET}"
|
||||
docker_cmd node check-locales.js
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Compiling locales ...${RESET}"
|
||||
docker_cmd yarn locale-compile
|
||||
docker_cmd chown -R "$(id -u):$(id -g)" /app/frontend/src/locale/lang
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Running eslint ...${RESET}"
|
||||
docker_cmd yarn eslint src
|
||||
docker_cmd yarn eslint -f junit src -o eslint.xml
|
||||
#echo -e "${BLUE}❯ ${CYAN}Running tests ...${RESET}"
|
||||
#docker_cmd yarn test --coverage --watchAll=false --testResultsProcessor ./node_modules/jest-junit
|
||||
echo -e "${BLUE}❯ ${CYAN}Building Frontend ...${RESET}"
|
||||
docker_cmd yarn build
|
||||
docker_cmd chown -R "$(id -u):$(id -g)" /app/frontend
|
||||
echo -e "${BLUE}❯ ${GREEN}Building Frontend Complete${RESET}"
|
||||
|
||||
# to avoid CRA ejection, just copy these build files over to embed in the backend
|
||||
rm -rf ${BACKEND_ASSETS}
|
||||
cp -pr frontend/build "${BACKEND_ASSETS}"
|
||||
echo -e "${BLUE}❯ ${GREEN}Copied build to ${BACKEND_ASSETS}${RESET}"
|
||||
|
||||
rm -rf frontend/node_modules
|
||||
|
||||
trap "docker_cmd chown -R $(id -u):$(id -g) /app/frontend" EXIT
|
105
scripts/ci/fulltest-cypress
Executable file
105
scripts/ci/fulltest-cypress
Executable file
@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# remember this is running in "ci" folder..
|
||||
|
||||
# Colors
|
||||
BLUE='\E[1;34m'
|
||||
CYAN='\E[1;36m'
|
||||
GREEN='\E[1;32m'
|
||||
RESET='\E[0m'
|
||||
YELLOW='\E[1;33m'
|
||||
|
||||
export BLUE CYAN GREEN RESET YELLOW
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Starting fullstack cypress testing ...${RESET}"
|
||||
|
||||
NETWORK_NAME="${COMPOSE_PROJECT_NAME}_default"
|
||||
|
||||
# $1: container_name
|
||||
get_container_ip () {
|
||||
local container_name=$1
|
||||
local container
|
||||
local ip
|
||||
container=$(docker-compose ps -q "${container_name}" | tail -n1)
|
||||
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.IPAddress}}" "$container")
|
||||
echo "$ip"
|
||||
}
|
||||
|
||||
# $1: container_name
|
||||
get_container_aliases () {
|
||||
local container_name=$1
|
||||
local container
|
||||
local ip
|
||||
container=$(docker-compose ps -q "${container_name}" | tail -n1)
|
||||
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.Aliases}}" "$container")
|
||||
echo "$ip"
|
||||
}
|
||||
|
||||
# Bring up a stack, in steps so we can inject IPs everywhere
|
||||
docker-compose up -d pdns pdns-db
|
||||
PDNS_IP=$(get_container_ip "pdns")
|
||||
echo -e "${BLUE}❯ ${YELLOW}PDNS IP is ${PDNS_IP}${RESET}"
|
||||
|
||||
# adjust the dnsrouter config
|
||||
LOCAL_DNSROUTER_CONFIG="$DIR/../../docker/dev/dnsrouter-config.json"
|
||||
rm -rf "$LOCAL_DNSROUTER_CONFIG.tmp"
|
||||
# IMPORTANT: changes to dnsrouter-config.json will affect this line:
|
||||
jq --arg a "$PDNS_IP" '.servers[0].upstreams[1].upstream = $a' "$LOCAL_DNSROUTER_CONFIG" > "$LOCAL_DNSROUTER_CONFIG.tmp"
|
||||
|
||||
docker-compose up -d dnsrouter
|
||||
DNSROUTER_IP=$(get_container_ip "dnsrouter")
|
||||
echo -e "${BLUE}❯ ${YELLOW}DNS Router IP is ${DNSROUTER_IP}"
|
||||
|
||||
# mount the resolver
|
||||
LOCAL_RESOLVE="$DIR/../../docker/dev/resolv.conf"
|
||||
rm -rf "${LOCAL_RESOLVE}"
|
||||
printf "nameserver %s\noptions ndots:0" "${DNSROUTER_IP}" > "${LOCAL_RESOLVE}"
|
||||
|
||||
# bring up all remaining containers, except cypress!
|
||||
docker-compose up -d --remove-orphans fullstack stepca
|
||||
|
||||
# wait for main container to be healthy
|
||||
bash "$DIR/../wait-healthy" "$(docker-compose ps -q fullstack)" 120
|
||||
|
||||
# Run tests
|
||||
rm -rf "$DIR/../../test/results"
|
||||
docker-compose up cypress
|
||||
|
||||
# Get results
|
||||
docker cp -L "$(docker-compose ps -q cypress):/test/results" "$DIR/../../test/"
|
||||
docker cp -L "$(docker-compose ps -q fullstack):/data/logs" "$DIR/../../test/results/"
|
||||
|
||||
echo -e "${BLUE}❯ ${GREEN}Fullstack cypress testing complete${RESET}"
|
||||
|
||||
# ----------------- Debug Report ----------------------
|
||||
# echo ip address of every docker container in stack
|
||||
# echo the hostnames and aliases of them
|
||||
# dns lookups from main container
|
||||
echo -e "${BLUE}============================================${RESET}"
|
||||
|
||||
FULLSTACK_IP=$(get_container_ip "fullstack")
|
||||
FULLSTACK_ALIASES=$(get_container_aliases "fullstack")
|
||||
echo -e "${YELLOW}fullstack IP: ${GREEN}${FULLSTACK_IP}${RESET}"
|
||||
echo -e "${YELLOW}fullstack Aliases: ${CYAN}${FULLSTACK_ALIASES}${RESET}"
|
||||
|
||||
STEPCA_IP=$(get_container_ip "stepca")
|
||||
STEPCA_ALIASES=$(get_container_aliases "stepca")
|
||||
echo -e "${YELLOW}stepca IP: ${GREEN}${STEPCA_IP}${RESET}"
|
||||
echo -e "${YELLOW}stepca Aliases: ${CYAN}${STEPCA_ALIASES}${RESET}"
|
||||
|
||||
PDNS_IP=$(get_container_ip "pdns")
|
||||
STEPCA_ALIASES=$(get_container_aliases "stepca")
|
||||
echo -e "${YELLOW}pdns IP: ${GREEN}${PDNS_IP}${RESET}"
|
||||
echo -e "${YELLOW}pdns Aliases: ${CYAN}${PDNS_ALIASES}${RESET}"
|
||||
|
||||
PDNSDB_IP=$(get_container_ip "pdns-db")
|
||||
PDNSDB_ALIASES=$(get_container_aliases "pdns-db")
|
||||
echo -e "${YELLOW}pdns-db IP: ${GREEN}${PDNSDB_IP}${RESET}"
|
||||
echo -e "${YELLOW}pdns-db Aliases: ${CYAN}${PDNSDB_ALIASES}${RESET}"
|
||||
|
||||
DNSROUTER_IP=$(get_container_ip "dnsrouter")
|
||||
DNSROUTER_ALIASES=$(get_container_aliases "dnsrouter")
|
||||
echo -e "${YELLOW}dnsrouter IP: ${GREEN}${DNSROUTER_IP}${RESET}"
|
||||
echo -e "${YELLOW}dnsrouter Aliases: ${CYAN}${DNSROUTER_ALIASES}${RESET}"
|
70
scripts/ci/test-backend
Executable file
70
scripts/ci/test-backend
Executable file
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
IMAGE=jc21/gotools:latest
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
. "$DIR/../.common.sh"
|
||||
|
||||
BUILD_DATE=$(date '+%Y-%m-%d %T %Z')
|
||||
NOW=$(date --rfc-3339=s)
|
||||
cd $DIR/../..
|
||||
|
||||
if [ "$BUILD_COMMIT" = "" ]; then
|
||||
BUILD_COMMIT=$(git log -n 1 --format=%h)
|
||||
fi
|
||||
|
||||
if [ "$BUILD_VERSION" = "" ]; then
|
||||
BUILD_VERSION=$(cat .version)
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}❯ ${GREEN}test-backend: ${YELLOW}${1:-}${RESET}"
|
||||
echo " BUILD_COMMIT: ${BUILD_COMMIT:-notset}"
|
||||
echo " BUILD_DATE: $BUILD_DATE"
|
||||
echo " BUILD_VERSION: $BUILD_VERSION"
|
||||
echo " CGO_ENABLED: ${CGO_ENABLED:-not set}"
|
||||
echo " GO111MODULE: ${GO111MODULE:-}"
|
||||
echo " GOPRIVATE: ${GOPRIVATE:-}"
|
||||
echo " GOPROXY: ${GOPROXY:-}"
|
||||
echo " NOW: $NOW"
|
||||
|
||||
if [ "${1:-}" = "--inside-docker" ]; then
|
||||
mkdir -p /workspace
|
||||
echo -e "${BLUE}❯ ${CYAN}Nancy setup${RESET}"
|
||||
cd /workspace
|
||||
# go get github.com/sonatype-nexus-community/nancy
|
||||
cp /app/backend/go.mod /app/backend/go.sum /app/backend/.nancy-ignore .
|
||||
go mod download
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Nancy testing${RESET}"
|
||||
go list -json -m all | nancy sleuth --quiet --username "${NANCY_USER}" --token "${NANCY_TOKEN:-}"
|
||||
rm -rf /workspace
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Testing backend code${RESET}"
|
||||
cd /app/backend
|
||||
[ -z "$(go tool fix -diff ./internal)" ]
|
||||
richgo test -cover -v ./internal/...
|
||||
richgo test -bench=. ./internal/...
|
||||
golangci-lint -v run ./...
|
||||
else
|
||||
# run this script from within docker
|
||||
docker pull "${IMAGE}"
|
||||
docker run --rm \
|
||||
-e BUILD_COMMIT="${BUILD_COMMIT:-notset}" \
|
||||
-e BUILD_DATE="$BUILD_DATE" \
|
||||
-e BUILD_VERSION="$BUILD_VERSION" \
|
||||
-e GOARCH="${2}" \
|
||||
-e GOOS="${1}" \
|
||||
-e GOPRIVATE="${GOPRIVATE:-}" \
|
||||
-e GOPROXY="${GOPROXY:-}" \
|
||||
-e NOW="$NOW" \
|
||||
-e SENTRY_DSN="${SENTRY_DSN:-}" \
|
||||
-e TZ="${TZ:-Australia/Brisbane}" \
|
||||
-v "$(pwd):/app" \
|
||||
-w '/app/backend' \
|
||||
"${IMAGE}" \
|
||||
/app/scripts/ci/test-backend --inside-docker
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}❯ ${GREEN}test-backend ${YELLOW}${1:-} ${GREEN}completed${RESET}"
|
||||
exit 0
|
@ -7,7 +7,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
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"
|
||||
docker run --rm -e CI=true -v "$(pwd)/docs:/app/docs" -w /app/docs node:latest 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}"
|
||||
|
@ -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
|
17
scripts/frontend-lint
Executable file
17
scripts/frontend-lint
Executable file
@ -0,0 +1,17 @@
|
||||
#!/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}Linting Frontend ...${RESET}"
|
||||
docker run --rm -e CI=true -v "$(pwd)/frontend:/app/frontend" -w /app/frontend node:latest sh -c "yarn install && yarn eslint src;chown -R $(id -u):$(id -g) /app/frontend"
|
||||
RES=$?
|
||||
echo -e "${BLUE}❯ ${GREEN}Linting Frontend Complete${RESET}"
|
||||
exit $RES
|
||||
else
|
||||
echo -e "${RED}❯ docker command is not available${RESET}"
|
||||
exit 1
|
||||
fi
|
33
scripts/go-multiarch-wrapper
Executable file
33
scripts/go-multiarch-wrapper
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
. "$DIR/.common.sh"
|
||||
|
||||
export GOOS=linux
|
||||
|
||||
# Determine the correct binary file for the architecture given
|
||||
case ${TARGETPLATFORM:-} in
|
||||
linux/arm64)
|
||||
export GOARCH=arm64
|
||||
;;
|
||||
|
||||
linux/arm/v7)
|
||||
export GOARCH=arm
|
||||
;;
|
||||
|
||||
linux/amd64)
|
||||
export GOARCH=amd64
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Building binary for ${YELLOW}${GOARCH} (${TARGETPLATFORM:-})${RESET}"
|
||||
|
||||
go build \
|
||||
-ldflags "-w -s -X main.commit=${BUILD_COMMIT:-notset} -X main.version=${BUILD_VERSION} -X main.sentryDSN=${SENTRY_DSN:-}" \
|
||||
-o "${1:-/dist/server}" \
|
||||
./cmd/server
|
||||
|
||||
# test binary
|
||||
/dist/server --version
|
||||
|
||||
echo -e "${BLUE}❯ ${CYAN}Build binary complete${RESET}"
|
@ -8,7 +8,7 @@ BLUE='\E[1;34m'
|
||||
GREEN='\E[1;32m'
|
||||
RESET='\E[0m'
|
||||
|
||||
S6_OVERLAY_VERSION=1.22.1.0
|
||||
S6_OVERLAY_VERSION=2.2.0.3
|
||||
TARGETPLATFORM=$1
|
||||
|
||||
# Determine the correct binary file for the architecture given
|
||||
@ -28,7 +28,8 @@ 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 /
|
||||
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 /
|
||||
rm -rf "/tmp/s6-overlay-${S6_ARCH}.tar.gz"
|
||||
|
||||
echo -e "${BLUE}❯ ${GREEN}S6-overlay install Complete${RESET}"
|
||||
|
17
scripts/sqlite
Executable file
17
scripts/sqlite
Executable file
@ -0,0 +1,17 @@
|
||||
#!/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 ""
|
||||
inform "Tip: List tables with: \\dt"
|
||||
echo ""
|
||||
|
||||
docker-compose exec npm usql /data/nginxproxymanager.db
|
||||
else
|
||||
echo -e "${RED}❯ docker-compose command is not available${RESET}"
|
||||
fi
|
@ -1,27 +1,55 @@
|
||||
#!/bin/bash -e
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
. "$DIR/.common.sh"
|
||||
|
||||
get_container_ip () {
|
||||
local container_name=$1
|
||||
local container
|
||||
local ip
|
||||
container=$(docker-compose ps -q "${container_name}" | tail -n1)
|
||||
ip=$(docker inspect -f "{{.NetworkSettings.Networks.npmdev_default.IPAddress}}" "$container")
|
||||
echo "$ip"
|
||||
}
|
||||
|
||||
# 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
|
||||
# Bring up a stack, in steps so we can inject IPs everywhere
|
||||
docker-compose up -d pdns pdns-db
|
||||
PDNS_IP=$(get_container_ip "pdns")
|
||||
echo -e "${BLUE}❯ ${YELLOW}PDNS IP is ${PDNS_IP}${RESET}"
|
||||
|
||||
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 ""
|
||||
# adjust the dnsrouter config
|
||||
LOCAL_DNSROUTER_CONFIG="$DIR/../docker/dev/dnsrouter-config.json"
|
||||
rm -rf "$LOCAL_DNSROUTER_CONFIG.tmp"
|
||||
# IMPORTANT: changes to dnsrouter-config.json will affect this line:
|
||||
jq --arg a "$PDNS_IP" '.servers[0].upstreams[1].upstream = $a' "$LOCAL_DNSROUTER_CONFIG" > "$LOCAL_DNSROUTER_CONFIG.tmp"
|
||||
|
||||
# dnsrouter
|
||||
docker-compose up -d dnsrouter
|
||||
DNSROUTER_IP=$(get_container_ip 'dnsrouter')
|
||||
echo -e "${BLUE}❯ ${YELLOW}DNS Router IP is ${DNSROUTER_IP}${RESET}"
|
||||
|
||||
# mount the resolver
|
||||
LOCAL_RESOLVE="$DIR/../docker/dev/resolv.conf"
|
||||
rm -rf "${LOCAL_RESOLVE}"
|
||||
printf "nameserver %s\noptions ndots:0" "${DNSROUTER_IP}" > "${LOCAL_RESOLVE}"
|
||||
|
||||
# bring things up, but only what we haven't already created
|
||||
docker-compose up -d --remove-orphans --force-recreate --build npm pebble stepca swagger
|
||||
|
||||
if [ "$1" == "-f" ]; then
|
||||
echo -e "${BLUE}❯ ${YELLOW}Following Backend Container:${RESET}"
|
||||
docker logs -f npm_core
|
||||
docker logs -f npmdev-npm-1
|
||||
else
|
||||
echo -e "${YELLOW}Hint:${RESET} You can follow the output of some of the containers with:"
|
||||
echo " docker logs -f npm_core"
|
||||
echo -e "${YELLOW}Tip:${RESET} You can follow the output of some of the containers with:"
|
||||
echo " docker logs -f npmdev-npm-1"
|
||||
echo -e "${YELLOW}Tip:${RESET} Open a database terminal with:"
|
||||
echo " ./scripts/sqlite"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}❯ docker-compose command is not available${RESET}"
|
||||
|
@ -7,7 +7,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
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"
|
||||
docker-compose exec -T npm bash -c "cd /app/backend && task test"
|
||||
else
|
||||
echo -e "${RED}❯ docker-compose command is not available${RESET}"
|
||||
fi
|
||||
|
@ -5,29 +5,28 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Waits for a docker container to be healthy."
|
||||
echo "Usage: $0 docker-container"
|
||||
echo "Usage: $0 docker-container 30"
|
||||
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++))
|
||||
is_up() {
|
||||
docker exec "$SERVICE" /bin/healthcheck.sh
|
||||
}
|
||||
|
||||
if [ "$LOOPCOUNT" == "$LIMIT" ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
i=0
|
||||
while ! is_up; do
|
||||
i=$((i + 1))
|
||||
if [ "$i" == "$LIMIT" ]; then
|
||||
echo -e "${BLUE}❯ ${RED}Timed out waiting for healthy${RESET}"
|
||||
docker logs --tail 50 "$SERVICE"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo ""
|
||||
|
Reference in New Issue
Block a user