#!/usr/bin/env bash
#
# Build and deploy Clipper.
#
# Dependencies:
#
# docker
# pv (pacman -S pv)
# bzip2
#
# To run migrations from container:
#
# docker-compose run --no-deps --entrypoint /bin/sh clipper-staging -c '/bin/migrate -path /app/migrations -database $DATABASE_URL up'
#
# TODO: production build
set -ex

export DOCKER_BUILDKIT=1

docker build \
  -t netfluxio/clipper-staging:latest \
  --build-arg API_URL=https://clipper-staging.netflux.io \
  .

docker save netfluxio/clipper-staging:latest | bzip2 | pv | ssh netflux 'bunzip2 | docker load'
