2020-12-09 16:20:24 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
build_octo_cli_docker_image() {
|
2021-07-13 11:53:53 +03:00
|
|
|
nix-build ./nix -A octo-cli-container -o "$1"
|
2020-12-09 16:20:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
build_octopod_server_docker_image() {
|
2021-07-13 11:53:53 +03:00
|
|
|
nix-build ./nix -A octopod-server-container --arg migrations "$1" -o "$2"
|
2020-12-09 16:20:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
push_docker_images() {
|
|
|
|
outfile=latest-octopod-server-docker
|
|
|
|
for image_name in $octo_cli_docker $octopod_server_docker; do
|
|
|
|
image_type=$(echo "$image_name" | cut -d- -f1)
|
|
|
|
image=$(ls -ls "$image_name" | awk '{print $12}')
|
|
|
|
echo "size: $(du -sh $image)"
|
|
|
|
docker load --input "$image" | tee "$outfile"
|
|
|
|
nixcontainer=$(awk '{print $3}' $outfile)
|
|
|
|
docker tag "$nixcontainer" "typeable/${image_type}:$1"
|
|
|
|
docker push "typeable/${image_type}:$1"
|
|
|
|
echo "Published: ${image_type}:$1"
|
|
|
|
done
|
|
|
|
rm $outfile
|
|
|
|
}
|
|
|
|
|
|
|
|
build_docker_images() {
|
|
|
|
build_octo_cli_docker_image "$octo_cli_docker"
|
|
|
|
build_octopod_server_docker_image "$migrations" "$octopod_server_docker"
|
|
|
|
}
|
|
|
|
|
|
|
|
export tag=$(git rev-parse HEAD)
|
|
|
|
export migrations="./migrations"
|
|
|
|
export octo_cli_docker="octo-docker"
|
|
|
|
export octopod_server_docker="octopod-server-docker"
|
|
|
|
|
|
|
|
case "$1" in
|
2021-07-13 11:53:53 +03:00
|
|
|
build-and-push)
|
|
|
|
echo "$1 mode"
|
2020-12-09 16:20:24 +03:00
|
|
|
|
2021-07-13 11:53:53 +03:00
|
|
|
if test -z "$2"; then
|
|
|
|
echo "Please provide a tag to upload to"
|
2020-12-09 16:20:24 +03:00
|
|
|
exit 1
|
2021-07-13 11:53:53 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
build_docker_images
|
|
|
|
push_docker_images $2
|
|
|
|
;;
|
|
|
|
build)
|
|
|
|
echo "$1 mode"
|
|
|
|
build_docker_images
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "usage:"
|
|
|
|
echo " $0 build Builds the docker images."
|
|
|
|
echo " $0 build-and-push <tag> Builds the docker images and uploads it to Docker Hub under the tag <tag>."
|
|
|
|
exit 1
|
|
|
|
;;
|
2020-12-09 16:20:24 +03:00
|
|
|
esac
|