#!/bin/sh
# using sh, is run from alpine

embed_bin_path=/tmp/gonicembed
assets_path=server/assets

# only build once for some slightly faster live page reloading
test ! -e "$embed_bin_path" && go build \
    -o "$embed_bin_path" \
    cmd/gonicembed/main.go

find $assets_path/ \
    -type f \
    ! -name '*.go' \
    -exec "$embed_bin_path" \
        -out-path $assets_path/assets.gen.go \
        -package-name assets \
        -assets-var-name Bytes \
        -asset-path-prefix $assets_path/ \
        {} +
