1#!/bin/bash
2while getopts ":r:j:t:" OPTION
3do
4	case $OPTION in
5		t)
6			TAG=$OPTARG;;
7		j)
8			THREADS=$OPTARG;;
9		r)
10			REPOSITORY=$OPTARG;;
11
12		\?)
13			echo "Please use the -r tag to set a repository, -j tag to set the number of threads for make and -t flag to set a tag"
14			exit
15			;;
16	esac
17done
18
19docker build -t $REPOSITORY . --build-arg no_threads=$THREADS --build-arg repository=$REPOSITORY --build-arg tag=$TAG
20docker run -dit --name palisade -p 80:80 $REPOSITORY
21docker commit palisade palisade:$TAG
22docker login registry.gitlab.com
23docker image tag palisade:$TAG registry.gitlab.com/palisade/$REPOSITORY/$TAG:$TAG
24docker push registry.gitlab.com/palisade/$REPOSITORY/$TAG:$TAG
25