-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-local.sh
More file actions
executable file
·50 lines (42 loc) · 1.84 KB
/
Copy pathbuild-local.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.84 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
43
44
45
46
47
48
49
50
#!/bin/sh
# Build tinycode-container locally using source from sibling directories.
# Copies source (excluding node_modules/.git) into a temp build context,
# then runs podman build from there.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TINYCODE_SRC="${TINYCODE_SRC:-/Users/bjohns/projects/tinycode}"
OH_MY_TINY_SRC="${OH_MY_TINY_SRC:-/Users/bjohns/projects/oh-my-tiny}"
IMAGE_TAG="${IMAGE_TAG:-tinycode-container:local}"
BUILD_PLATFORM="${BUILD_PLATFORM:-}"
BUILD_DIR="$(mktemp -d /tmp/tinycode-container-build.XXXXXX)"
trap 'rm -rf "$BUILD_DIR"' EXIT
echo "==> Build context: $BUILD_DIR"
echo "==> tinycode source: $TINYCODE_SRC"
echo "==> oh-my-tiny source: $OH_MY_TINY_SRC"
echo ""
echo "==> Copying tinycode source (excluding node_modules, dist, .git)..."
rsync -a --exclude=node_modules --exclude=dist --exclude=.git \
"$TINYCODE_SRC/" "$BUILD_DIR/tinycode-src/"
echo "==> Copying oh-my-tiny source (excluding node_modules, dist, .git)..."
rsync -a --exclude=node_modules --exclude=dist --exclude=.git \
"$OH_MY_TINY_SRC/" "$BUILD_DIR/oh-my-tiny-src/"
echo "==> Copying ContainerFile.local, entrypoint.sh, and config..."
cp "$SCRIPT_DIR/ContainerFile.local" "$BUILD_DIR/ContainerFile.local"
cp "$SCRIPT_DIR/entrypoint.sh" "$BUILD_DIR/entrypoint.sh"
cp -r "$SCRIPT_DIR/config" "$BUILD_DIR/config"
echo "==> Starting build (this takes 5-10 min on first run)..."
echo ""
podman build \
${BUILD_PLATFORM:+--platform "$BUILD_PLATFORM"} \
-f "$BUILD_DIR/ContainerFile.local" \
-t "$IMAGE_TAG" \
"$BUILD_DIR"
echo ""
echo "==> Build complete: $IMAGE_TAG"
echo ""
echo "Quick tests:"
echo " podman run --rm --entrypoint id $IMAGE_TAG"
echo " podman run -d --name tinycode-test -p 4096:4096 $IMAGE_TAG"
echo " curl -s http://localhost:4096/global/health | jq ."
echo " open http://localhost:4096"
echo " podman stop tinycode-test && podman rm tinycode-test"