|
1 | 1 | #!/bin/sh |
2 | 2 |
|
3 | | -# variables that can be set |
4 | | -# DEBUG : set to echo to print command and not execute |
5 | | -# PUSH : set to push to push, anthing else not to push. If not set |
6 | | -# the program will push if master or develop. |
7 | | -# PROJECT : the project to add to the image, default is NCSA |
8 | | -# VERSION : the list of tags to use, if not set this will be 2 |
9 | | - |
10 | 3 | #DEBUG=echo |
11 | 4 |
|
12 | | -# set default for clowder |
13 | | -PROJECT=${PROJECT:-"clowder"} |
14 | | - |
15 | | -RM=${RM:-"rm"} |
16 | | - |
17 | | -# find out version and if we should push |
18 | | -BRANCH="$(git rev-parse --abbrev-ref HEAD)" |
19 | | -VERSION=${VERSION:-"2"} |
20 | | -if [ "$BRANCH" = "master" ]; then |
21 | | - PUSH=${PUSH:-"push"} |
22 | | -else |
23 | | - PUSH=${PUSH:-""} |
24 | | -fi |
25 | | - |
26 | | -# keep track of which latest amde |
27 | | -LATEST="" |
28 | | - |
29 | | -# helper to create the docker container |
30 | | -# $1 - folder that contains the Dockerfile |
31 | | -# $2 - name of docker image |
32 | | -# $3 - name of Dockerfile |
33 | | -create() { |
34 | | - if [ -z "$1" ]; then echo "Missing repo/Dockerfile name."; exit -1; fi |
35 | | - if [ -z "$2" ]; then echo "Missing name for $1."; exit -1; fi |
36 | | - |
37 | | - DOCKERFILE=${3:-"$1/Dockerfile"} |
38 | | - |
39 | | - # create image using temp id |
40 | | - local ID=$(uuidgen) |
41 | | - ${DEBUG} docker build --tag $$ --file ${DOCKERFILE} $1 |
42 | | - if [ $? -ne 0 ]; then |
43 | | - echo "FAILED build of $1/${DOCKERFILE}" |
44 | | - exit -1 |
45 | | - fi |
46 | | - |
47 | | - # tag all versions |
48 | | - for v in $VERSION; do |
49 | | - if [ "$PROJECT" = "" ]; then |
50 | | - ${DEBUG} docker tag $$ ${2}:${v} |
51 | | - else |
52 | | - for p in ${PROJECT}; do |
53 | | - NAME=$2 |
54 | | - ${DEBUG} docker tag $$ ${p}/${NAME}:${v} |
55 | | - if [ "$PUSH" = "push" ]; then |
56 | | - ${DEBUG} docker push ${p}/${NAME}:${v} |
57 | | - fi |
58 | | - done |
59 | | - fi |
60 | | - done |
61 | | - |
62 | | - # tag version as latest, but don't push |
63 | | - if [ ! "$BRANCH" = "master" ]; then |
64 | | - if [ "$PROJECT" = "" ]; then |
65 | | - ${DEBUG} docker tag $$ ${2}:latest |
66 | | - LATEST="$LATEST ${2}:latest" |
67 | | - else |
68 | | - for p in ${PROJECT}; do |
69 | | - NAME=$2 |
70 | | - ${DEBUG} docker tag $$ ${p}/${NAME}:latest |
71 | | - LATEST="$LATEST ${p}/${NAME}:latest" |
72 | | - done |
73 | | - fi |
74 | | - fi |
| 5 | +# build docker container |
| 6 | +${DEBUG} docker build --tag clowder/pyclowder:2 . |
| 7 | +${DEBUG} docker build --tag clowder/pyclowder:onbuild --file Dockerfile.onbuild . |
75 | 8 |
|
76 | | - # delete image with temp id |
77 | | - ${DEBUG} docker rmi $$ |
78 | | -} |
| 9 | +# build sample extractors |
| 10 | +${DEBUG} docker build --tag clowder/extractors-wordcount:2 sample-extractors/wordcount |
79 | 11 |
|
80 | | -# Create the docker containers |
81 | | -create "." "pyclowder" |
82 | | -create "sample-extractors/wordcount" "extractors-wordcount" |
83 | 12 |
|
84 | | -# remove latest tags |
85 | | -if [ "$RM" = "rm" ]; then |
86 | | - for r in $LATEST; do |
87 | | - ${DEBUG} docker rmi ${r} |
88 | | - done |
| 13 | +if [ "$(git rev-parse --abbrev-ref HEAD)" = "master" ]; then |
| 14 | + ${DEBUG} docker push clowder/pyclowder:2 |
| 15 | + ${DEBUG} docker push clowder/pyclowder:onbuild |
| 16 | + ${DEBUG} docker push clowder/extractors-wordcount:2 |
89 | 17 | fi |
0 commit comments