Skip to content

Instantly share code, notes, and snippets.

@ecatanzani
Last active November 14, 2018 10:32
Show Gist options
  • Save ecatanzani/915f83b30125b128a778eeede0674be6 to your computer and use it in GitHub Desktop.
Save ecatanzani/915f83b30125b128a778eeede0674be6 to your computer and use it in GitHub Desktop.
Docker based compiler
#!/usr/bin/env bash
SOURCE="$1"
EXITPATH="$2"
FILE=${SOURCE##*/}
BASE=${FILE%.*}
echo -e "\e[31mReaching tmp dir...\e[0m"
cd /tmp &&
echo -e "\e[31mCopying package into the container...\e[0m"
cp ${SOURCE} . &&
echo -e "\e[31mUnzipping package...\e[0m"
unzip ${FILE} &&
echo -e "\e[31mAccessing compilation files...\e[0m"
cd ${BASE} &&
echo -e "\e[31mCompiling...\e[0m"
make all &&
echo -e "\e[31mCompressing result files\e[0m"
cd .. && zip -r ${FILE} ${BASE} &&
echo -e "\e[31mMoving final package...\e[0m"
cp ${FILE} ${EXITPATH} &&
echo -e "\e[31mCleaning...\e[0m"
rm -rf /tmp/*
#!/usr/bin/env bash
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-c|--container)
CONTAINER="$2"
shift
shift
;;
-s|--source)
SPATH="$2"
shift
shift
;;
-p|--path)
OUTPATH="$2"
shift
shift
;;
-b|--builder)
BUILDER="$2"
shift
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
EPOINT="${BUILDER} ${SPATH} ${OUTPATH}"
if [[ "$CONTAINER" = "centos" ]]; then
CMD="docker run --rm -it -v /Users/enrico/:/userhome --user $(id -u) rootframework:centos ${EPOINT}"
${CMD}
elif [[ "$CONTAINER" = "ubuntu" ]]; then
CMD="docker run --rm -it -v /Users/enrico/:/userhome --user $(id -u) rootframework:ubuntu ${EPOINT}"
${CMD}
else
echo "Unkown container selected"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment