-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-local.sh
More file actions
executable file
·42 lines (34 loc) · 1.03 KB
/
build-local.sh
File metadata and controls
executable file
·42 lines (34 loc) · 1.03 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
39
40
41
42
#!/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="$SCRIPT_DIR/public"
IMAGE_NAME="100hellos-docs:local"
for dir in "$HELLOS_DIR" "$FRAGLET_DIR" ; do
if ! test -d "$dir" ; then
echo "fatal: $dir not found" >&2
exit 1
fi
done
echo "==> Building docs container..."
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
rm -rf "$OUTPUT_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/"