Merge "New JJB files for Docker container builds"
[ci-management.git] / jjb / shell / build-docker.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 DOCKER_REPO='nexus3.akraino.org:10003'
18
19 set -e -u -x -o pipefail
20
21 echo '---> Starting build-docker'
22
23 case "$PROJECT" in
24 portal_user_interface)
25     CON_NAME='akraino-portal'
26     VERSION=`xmlstarlet sel -N "x=http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" AECPortalMgmt/pom.xml`
27     WARFILE="https://nexus.akraino.org/repository/maven-snapshots/org/akraino/portal/portal/${VERSION}/portal-${VERSION}.war"
28     curl -O ${WARFILE}
29     ln $(basename ${WARFILE}) AECPortalMgmt.war
30
31     (
32         echo 'FROM tomcat:8.5.31'
33         echo 'COPY AECPortalMgmt.war /usr/local/tomcat/webapps'
34     ) > Dockerfile
35     ;;
36
37 camunda_workflow)
38     CON_NAME='akraino-camunda-workflow-engine'
39     VERSION=`xmlstarlet sel -N "x=http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" akraino/pom.xml`
40     JARFILE="https://nexus.akraino.org/repository/maven-snapshots/org/akraino/camunda_workflow/${VERSION}/camunda_workflow-${VERSION}.jar"
41     curl -O ${JARFILE}
42     ;;
43
44 postgres_db_schema)
45     CON_NAME='akraino_schema_db'
46     source $WORKSPACE/version.properties
47     TARFILE="https://nexus.akraino.org/repository/maven-snapshots/org/akraino/camunda_workflow/${VERSION}/camunda_workflow-${VERSION}.tgz"
48     curl -O ${TARFILE}
49     (mkdir yaml_builds; cd yaml_builds; tar xfv ../$(basename ${TARFILE}))
50     mv yaml_builds/templates akraino-j2templates
51     ;;
52
53 *)
54     echo unknown project "$PROJECT"
55     exit 1
56     ;;
57 esac
58
59 # Build and push the Docker container
60 docker build -f Dockerfile -t ${CON_NAME}:${VERSION} .
61 docker tag ${CON_NAME}:${VERSION} ${DOCKER_REPO}/${CON_NAME}:${VERSION}
62 docker push ${DOCKER_REPO}/${CON_NAME}:${VERSION}
63
64 set +u +x