Fixing the docker file to set default python exec
[optf/osdf.git] / docker / build_image.sh
1 #!/bin/bash
2
3 # The script starts in the root folder of the repo, which has the following outline
4 # We fetch the version information from version.properties, build docker files and
5 # do a docker push. Since the job will be run under Jenkins, it will have the Nexus
6 # credentials
7 #
8 #  ├── docker
9 #  │   ├── Dockerfile
10 #  │   └── build_image.sh   <--- THIS SCRIPT is here
11 #  ├── docs
12 #  ├── osdf
13 #  ├── pom.xml
14 #  ├── test
15 #  └── version.properties   <--- Version information here
16
17 set -e
18
19 # Folder settings
20 DOCKER_REPOSITORY=nexus3.onap.org:10003
21 ORG=onap
22 PROJECT=optf-osdf
23 IMAGE_NAME=$DOCKER_REPOSITORY/$ORG/$PROJECT
24
25 # Version properties
26 source version.properties
27 VERSION=$release_version
28 STAGING=${release_version}-STAGING
29
30 function log_ts() {  # Log message with timestamp
31     echo [DEBUG LOG at $(date -u +%Y%m%d:%H%M%S)] "$@"
32 }
33
34 function build_image() {
35      log_ts Building Image in folder: $PWD
36      docker build -t ${IMAGE_NAME}:${VERSION} -t ${IMAGE_NAME}:latest -t ${IMAGE_NAME}:${STAGING} .
37      log_ts ... Built
38 }
39
40 function push_image(){
41      log_ts Pushing images: ${IMAGE_NAME}:\{$VERSION,$STAGING,latest\}
42      docker push ${IMAGE_NAME}:${VERSION}
43      docker push ${IMAGE_NAME}:${STAGING}
44      docker push ${IMAGE_NAME}:latest
45      log_ts ... Pushed images
46 }
47
48 (
49   cd $(dirname $0)
50   build_image
51   push_image
52 )