-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_run
More file actions
executable file
·33 lines (24 loc) · 1.13 KB
/
build_run
File metadata and controls
executable file
·33 lines (24 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
[[ -z "$INFO_LEVEL" ]] && source ./bits/bootstrap/logging
CMD=${CMD-}
NAME=${NAME-}
VERSION=${VERSION-latest}
LAUNCHER_DIR=${LAUNCHER_DIR-}
IMAGE_NAME=${IMAGE_NAME-$NAME:$VERSION}
IMAGE_RUN_NAME=${IMAGE_RUN_NAME-$NAME:$VERSION-pre}
notify " -- Running $CMD in DOCKER container $NAME ($VERSION)"
BUILD_OUTPUT=${LAUNCHER_DIR}/docker_build.log
TS=$(date +"%Y%m%d%H%M%S")
CID_FILE=${LAUNCHER_DIR}/$NAME-$VERSION-$TS.cid
(cd ${LAUNCHER_DIR} && IGNORE=$(docker run $@ --cidfile $CID_FILE $IMAGE_RUN_NAME $CMD >> $BUILD_OUTPUT 2>&1))
ERROR="Error running $CMD in DOCKER container $NAME ($VERSION), due to ..." ./bits/bootstrap/failonerrors $? $BUILD_OUTPUT
[ $? -ne 0 ] && exit 1
CONTAINER=$(cat $CID_FILE)
debug " -- Commiting resulting container to image $IMAGE_NAME"
DOCKER_ID=$(docker commit $CONTAINER $IMAGE_NAME)
[ $? -ne 0 ] && exit 1
IGNORE=$((docker rm -f $CONTAINER && rm $CID_FILE) >> $BUILD_OUTPUT 2>&1)
ERROR="Error stopping DOCKER container $CONTAINER running $CMD" ./bits/bootstrap/failonerrors $? $BUILD_OUTPUT
[ $? -ne 0 ] && exit 1
NAME=$NAME VERSION=latest DOCKER_ID=$DOCKER_ID ./bits/docker/tag
[ $? -ne 0 ] && exit 1