#!/bin/sh
# script/cibuild: run the CI build. It builds every image in the repo:
# the frontend image from Dockerfile and the backend image from
# Dockerfile.backend. Each Dockerfile runs its half of make check as a
# build step, so a successful cibuild implies the whole repo is green.
# This is the only build step the Gitea workflow runs.
set -eu

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

# build_image <dockerfile>: build one image from the repo root context.
# Every docker build CI performs goes through here, so build-wide flags
# only ever have to be added in one place.
build_image() {
    timeout 300 docker build -f "$1" .
}

main() {
    cd "$ROOT"
    build_image Dockerfile
    build_image Dockerfile.backend
}

main "$@"
