-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·38 lines (30 loc) · 1.08 KB
/
build.sh
File metadata and controls
executable file
·38 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MONOREPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
HELLOS_DIR="$MONOREPO_ROOT/100hellos"
FRAGLET_DIR="$MONOREPO_ROOT/fraglet"
OUTPUT_DIR="${OUTPUT_DIR:-$SCRIPT_DIR/public}"
IMAGE_NAME="ofthemachine/100hellos-docs:local"
echo "==> Checking out main branches..."
(cd "$HELLOS_DIR" && git fetch origin && git checkout origin/main)
(cd "$FRAGLET_DIR" && git fetch origin && git checkout origin/main)
echo "==> Building docs container..."
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
mkdir -p "$OUTPUT_DIR"
echo "==> Running build (preprocess + gatsby build)..."
docker run --rm \
--platform="linux/amd64" \
-v "$HELLOS_DIR":/mnt/100hellos:ro \
-v "$FRAGLET_DIR":/mnt/fraglet:ro \
-v "$OUTPUT_DIR":/static_site \
-e UID="$(id -u)" \
-e GID="$(id -g)" \
"$IMAGE_NAME"
echo ""
echo "==> Build complete. Output at: $OUTPUT_DIR"
echo ""
echo "Serve locally with:"
echo " docker run --rm -v '$OUTPUT_DIR':/usr/share/nginx/html:ro -p 8080:80 nginx:alpine"
echo ""
echo "Then open http://localhost:8080"