Last active
March 2, 2022 19:36
-
-
Save aerickson/3f785dd2fb75de27c30468dbac91cb96 to your computer and use it in GitHub Desktop.
docker_build_package_caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# script to build docker images and use a polipo proxy if present | |
# - works well for caching package fetches during apt install, etc | |
# | |
set -e | |
# set -x | |
container_name="fun_container_99" | |
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" | |
cd "${SCRIPTPATH}" | |
# cache http requests if proxy server is running | |
# see if the proxy is up | |
status=0 | |
nc -v -z localhost 8123 || status=$? | |
if [ "$status" == 0 ] ; then | |
# proxy is running | |
echo "* using proxy" | |
echo "" | |
proxy_host=host.docker.internal | |
export http_proxy="http://localhost:8123" | |
export https_proxy="http://localhost:8123" | |
docker build --build-arg http_proxy=http://$proxy_host:8123 \ | |
--build-arg https_proxy=http://$proxy_host:8123 \ | |
-t "$container_name" . | |
else | |
# proxy is not running | |
echo "* not using proxy" | |
echo "" | |
docker build -t "$container_name" . | |
fi | |
# docker run -it "$container_name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diskCacheRoot=/tmp/cache/polipo | |
logLevel=4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# runs polipo (https://www.irif.fr/~jch/software/polipo/) with a basic config | |
# `brew install polipo` works on OS X to install | |
set -e | |
mkdir -p /tmp/cache/polipo | |
polipo -c polipo.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment