git @ Cat's Eye Technologies The-Cannery / 53ab065
Clone a fresh copy of the source before building an image from it. Chris Pressey 3 years ago
1 changed file(s) with 15 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
0 #!/bin/sh
1
02 # Common script for building a Docker image.
13 # Usage: build-docker-image.sh <dir-containing-docker-config>
24
35 CONFIG_DIR=$1
4 . $CONFIG_DIR/settings.sh
6 if [ -r $CONFIG_DIR/settings.sh ]; then
7 . $CONFIG_DIR/settings.sh
8 else
9 echo "'$CONFIG_DIR' is not a valid configuration directory"
10 exit 1
11 fi
512
613 shelf_pwd() {
714 name="$1"
1623 }
1724
1825 if shelf_pwd ${SOURCE}; then
19 SRCDIR=`shelf_pwd ${SOURCE}`
26 GITDIR=`shelf_pwd ${SOURCE}`
2027 else
2128 echo "Please set SHELF_PATH to a directory where the source '${SOURCE}' can be found."
2229 exit 1
2633 DOCKERFILE=$CONFIG_DIR/Dockerfile
2734 IMAGENAME=$EXENAME
2835
29 find ${SRCDIR} -name '*.pyc' -exec rm {} \;
30 find ${SRCDIR} -name '__pycache__' -exec rm -r {} \;
36 SRCDIR=/tmp/$EXENAME
37
38 echo "Cloning ${GITDIR} to ${SRCDIR}..."
39
40 rm -rf ${SRCDIR}
41 (cd /tmp/ && git clone ${GITDIR} ${EXENAME})
3142
3243 docker container prune -f
3344 docker rmi ${ORGNAME}/${IMAGENAME}:${VERSION}