chore(docker): add .env.example and Docker Compose setup/build/run scripts
This commit is contained in:
parent
5701e77780
commit
a1f26bc61f
12 changed files with 943 additions and 7 deletions
82
scripts/build.sh
Executable file
82
scripts/build.sh
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/_compose.sh
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)/_compose.sh"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: ./scripts/build.sh [options] [-- <extra docker compose build args>]
|
||||
|
||||
Build the GCoordinator Docker image using BuildKit and compose configuration.
|
||||
|
||||
Options:
|
||||
--lan Use LAN compose override (default unless GCOORD_DEPLOY_MODE=cloudflare)
|
||||
--cloudflare Use Cloudflare Tunnel compose configuration
|
||||
--mode <lan|cloudflare> Explicitly select deployment mode
|
||||
--no-cache Pass --no-cache to docker compose build
|
||||
--pull Pass --pull to docker compose build
|
||||
--dry-run Print the compose command without executing it
|
||||
-h, --help Show this help message
|
||||
EOF
|
||||
}
|
||||
|
||||
REQ_MODE=""
|
||||
BUILD_FLAGS=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--lan)
|
||||
REQ_MODE="lan"
|
||||
shift
|
||||
;;
|
||||
--cloudflare)
|
||||
REQ_MODE="cloudflare"
|
||||
shift
|
||||
;;
|
||||
--mode)
|
||||
[[ $# -ge 2 ]] || die "--mode requires an argument."
|
||||
REQ_MODE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--mode=*)
|
||||
REQ_MODE="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--no-cache|--pull)
|
||||
BUILD_FLAGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
BUILD_FLAGS+=("$@")
|
||||
break
|
||||
;;
|
||||
*)
|
||||
die "Unknown option: $1 (pass extra compose build flags after '--', or run --help)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
MODE="$(resolve_mode "$REQ_MODE")"
|
||||
|
||||
if [[ -r /proc/meminfo ]]; then
|
||||
mem_kb="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo 2>/dev/null || echo 0)"
|
||||
swap_kb="$(awk '/^SwapTotal:/ {print $2}' /proc/meminfo 2>/dev/null || echo 0)"
|
||||
if [[ "$mem_kb" =~ ^[0-9]+$ && "$swap_kb" =~ ^[0-9]+$ ]] && [[ "$mem_kb" -lt 1500000 && "$swap_kb" -lt 1000000 ]]; then
|
||||
log_warn "Low RAM (~$((mem_kb / 1024)) MB) and low swap (~$((swap_kb / 1024)) MB) detected; Docker image compilation may need >= 1-2 GB swap."
|
||||
fi
|
||||
fi
|
||||
|
||||
log_info "Building GCoordinator image (mode=$MODE)..."
|
||||
export DOCKER_BUILDKIT=1
|
||||
export COMPOSE_DOCKER_CLI_BUILD=1
|
||||
run_compose "$MODE" build "${BUILD_FLAGS[@]}" gcoordinator
|
||||
Loading…
Add table
Add a link
Reference in a new issue