#!/bin/bash set -euo pipefail # Usage: # ./build.bash [app] build an in-tree app (default: lilush) # ./build.bash --pack --ref --name # build an external LILPACK repo into a # custom static binary # # In-tree builds use buildgen/apps/.lua. Pack builds clone at # inside the container and build from the pack's build/.lua # descriptor. is the descriptor's `binary` value and the output filename. PACK_URL="" PACK_REF="" APP="lilush" if [ "${1:-}" = "--pack" ]; then while [ $# -gt 0 ]; do case "$1" in --pack) PACK_URL="$2"; shift 2 ;; --ref) PACK_REF="$2"; shift 2 ;; --name) APP="$2"; shift 2 ;; *) echo "unknown option: $1" >&2; exit 1 ;; esac done if [ -z "$PACK_URL" ] || [ -z "$PACK_REF" ] || [ -z "$APP" ]; then echo "pack build requires --pack --ref --name " >&2 exit 1 fi else APP=${1:-lilush} fi if [ -n "$PACK_URL" ]; then # --no-cache so a re-pushed tag can't serve a stale cloned layer. docker build --no-cache \ --build-arg APP="${APP}" \ --build-arg PACK_URL="${PACK_URL}" \ --build-arg PACK_REF="${PACK_REF}" \ -t lilush-build . else docker build --build-arg APP="${APP}" -t lilush-build . fi docker cp $(docker create --name lilush-build lilush-build):/build/${APP} ./${APP} docker rm lilush-build