#!/usr/bin/env sh
# SPDX-FileCopyrightText: © 2020 Caleb Maclennan <caleb@alerque.com>
# SPDX-License-Identifier: GPL-3.0-only

set -e

: "${ARCHTAG:=latest}"

REVISION=$(git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')

RUNTIME_DEPS='diffutils entr font-v gftools git libarchive libgit2 make'\
' psautohint python python-babelfont python-brotli python-cffsubr'\
' python-defcon python-fontmake python-fonttools python-fs python-lxml'\
' python-pcpp python-skia-pathops python-ufo2ft python-ufolib2'\
' python-ufonormalizer python-unicodedata2 python-vttlib python-zopfli'\
' sfd2ufo sfdnormalize sfnt2woff-zopfli ttfautohint woff2 zsh'
BUILD_DEPS='base-devel cargo jq rust'

: "${DOCKER_BUILDKIT:=1}"
export DOCKER_BUILDKIT

docker build \
	--build-arg ARCHTAG="$ARCHTAG" \
	--build-arg REVISION="$REVISION" \
	--build-arg VERSION="${1:-$REVISION}" \
	--build-arg RUNTIME_DEPS="$RUNTIME_DEPS" \
	--build-arg BUILD_DEPS="$BUILD_DEPS" \
	--tag $DOCKER_REPO:$DOCKER_TAG \
	./
