#!/usr/bin/env bash # Use: ./build-and-minimize.bash # Makes a docker image, saves it as .tar, unpacks the tar, removes # the base Debian layer, and repacks it so I can upload to servers a little # faster. TEMP_GIBBERISH="ptth_build_L6KLMVS6" TEMP_TAR="$TEMP_GIBBERISH/ptth.tar" UPLOADABLE_TAR="$PWD/ptth_latest.tar.gz" # This is magic and will need to be updated whenever we update the # Debian layer. BOTTOM_LAYER="cec906613726ec32de92af0ec1cd6692c34df78782227f4415cd12c47a264dd4" mkdir -p "$TEMP_GIBBERISH/ptth" sudo docker build -t ptth:latest . sudo docker image save ptth:latest | pv > "$TEMP_TAR" tar -C "$TEMP_GIBBERISH/ptth" -xf "$TEMP_TAR" rm -rf "$TEMP_GIBBERISH/ptth/$BOTTOM_LAYER" pushd "$TEMP_GIBBERISH/ptth" tar -czf "$UPLOADABLE_TAR" . popd