#!/bin/sh
# script/docker: build the repo's Docker images, tagged from
# script/projectname: the frontend image as <name> and the backend image
# as <name>-server. Both build from the repo root as their context.
set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

main() {
    cd "$ROOT"
    name="$("$ROOT/script/projectname")"
    timeout 300 docker build -t "$name" -f Dockerfile .
    timeout 300 docker build -t "$name-server" -f Dockerfile.backend .
}

main "$@"
