#!/bin/bash
my_directory=$(pwd -P)
conda activate mypython3

## ragconnect
(cd ~/git/jastadd/ragconnect && git archive > ${my_directory}/ragconnect.tar)
(cd ~/git/jastadd/ragconnect/pages && mkdocs build && tar cf ${my_directory}/ragconnect_pages.tar ../public)

## minimal example
(cd ~/git/jastadd/minimal-ragconnect && git archive > ${my_directory}/minimal_example.tar)
(cd ~/git/jastadd/minimal-ragconnect/pages && mkdocs build && tar cf ${my_directory}/minimal_example_pages.tar ../public)

## containered
image_id_web=$(docker images --format="{{.Repository}} {{.ID}}" | grep models2022_web | head -n1 | cut -d' ' -f2)
image_id_mosquitto=$(docker images --format="{{.Repository}} {{.ID}}" | grep eclipse-mosquitto | head -n1 | cut -d' ' -f2)
image_id_rag=$(docker images --format="{{.Repository}} {{.ID}}" | grep models2022_rag_place_a | head -n1 | cut -d' ' -f2)
image_id_ros=$(docker images --format="{{.Repository}} {{.ID}}" | grep models2022_ros_place_b1 | head -n1 | cut -d' ' -f2)

docker save ${image_id_web} > models2022_web.tar
docker save ${image_id_mosquitto} > models2022_mosquitto.tar
docker save ${image_id_rag} > models2022_rag_place.tar
docker save ${image_id_ros} > models2022_ros_place.tar

## this workspace
tar cf workspace.tar docker-compose.yml config/* robotic-controller/vnc/* shared_directory_images/

## bundle everything together
zip models2022 \
    workspace.tar \
    ragconnect.tar \
    ragconnect_pages.tar \
    minimal_example.tar \
    minimal_example_pages.tar \
    models2022_web.tar \
    models2022_mosquitto.tar \
    models2022_rag_place.tar \
    models2022_ros_place.tar \
    README.md \
    links.md
