Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Can build grouper
  • Loading branch information
Jim Van Fleet committed Sep 1, 2016
0 parents commit 3aebcd3
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
@@ -0,0 +1,9 @@
bin/build.sh
bin/destroy.sh
bin/install.sh
bin/rebuild.sh
bin/rerun.sh
bin/run.sh
bin/start.sh
bin/stop.sh
bin/test.sh
41 changes: 41 additions & 0 deletions BINSCRIPTS.md
@@ -0,0 +1,41 @@
# util

This repository is intended to be downloaded into a container repository during development for convenience purposes. Since the major mechanisms of developing to the Docker container construction lifecycle are identical across container images, this repository allows for consistency and additional ease of use across all container images.

## Install

If you are reading this file in BINSCRIPTS.md, your container project is likely to be util-enabled.

To use these scripts yourself, issue this command:

```
curl "https://github.internet2.edu/raw/docker/util/master/bin/install.sh?token=AAAAE4VRBLPB8VExPHSR5nCe791IAYqaks5Xzug5wA%3D%3D" | bash
```

### common.bash

The installation process will create a common.bash file. This file should be the central, canonical authority for management of environment variables. While a subprocess may override them, the files in common.bash should be treated as authoritative defaults. Processes (e.g. `docker build`, `bats`, inside `Jenkinsfile`) can read this file and process the results therein.

You should edit this file to change the image name, and add any other helpful environment variables.

### Jenkinsfile

This will also install a Jenkinsfile to your repository, if it doesn't have one. This will ensure that your Jenkins pipeline can leverage these scripts in the way intended. Ensuring the commands that you issue on your laptop match the commands issued by the build pipeline is critical to ensure predictable, reliable results.

## Use


### Building

#### build.sh
`bin/build.sh `
#### destroy.sh
#### rebuild.sh

### Running
### rerun.sh
### run.sh


### Testing
#### test.sh
23 changes: 23 additions & 0 deletions Dockerfile
@@ -0,0 +1,23 @@
FROM bigfleet/grouper

ARG maintainer=my
ARG imagename=grouper
ARG version=2.3.0

LABEL Version=$version
ENV VERSION=$version
ENV TOMCAT_VERSION="6.0.35"

ENV MYSQL_DATABASE=grouper
ENV MYSQL_USER=grouper_user
ENV MYSQL_PASSWORD=3cf0ccc7d6b240390188367933c9cd90

ENV GROUPER_SYSTEM_PASSWORD=3cf0ccc7d6b240390188367933c9cd90
ENV MYSQL_HOST=mariadb

ADD ./container_files /root
COPY conf/grouper.installer.properties /opt/grouper/$version

RUN /root/container_start.sh

VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs
88 changes: 88 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,88 @@
node {

stage 'Checkout'

checkout scm

stage 'Acquire util'

sh 'mkdir -p tmp && mkdir -p bin'
dir('tmp'){
git([ url: "https://github.internet2.edu/docker/util.git",
credentialsId: "jenkins-github-access-token" ])
sh 'mv ./bin/* ../bin/.'
}
sh 'rm -rf tmp'

stage 'Setting build context'

def maintainer = maintainer()
def imagename = imagename()
def tag

// Tag images created on master branch with 'latest'
if(env.BRANCH_NAME == "master"){
tag = "latest"
}else{
tag = env.BRANCH_NAME
}

if(!imagename){
echo "You must define an imagename in common.bash"
currentBuild.result = 'FAILURE'
}
if(maintainer){
echo "Building ${imagename}:${tag} for ${maintainer}"
}

stage 'Build'
try{
sh 'bin/build.sh &> debug'
} catch(error) {
def error_details = readFile('./debug');
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
sh "rm -f ./debug"
handleError(message)
}

stage 'Tests'

try{
sh 'bin/test.sh &> debug'
} catch(error) {
def error_details = readFile('./debug');
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
sh "rm -f ./debug"
handleError(message)
}

stage 'Push'

docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") {
def baseImg = docker.build("$maintainer/$imagename")
baseImg.push("$tag")
}

stage 'Notify'

slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub"

}

def maintainer() {
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
matcher ? matcher[0][1] : 'tier'
}

def imagename() {
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
matcher ? matcher[0][1] : null
}

def handleError(String message){
echo "${message}"
currentBuild.setResult("FAILED")
slackSend color: 'danger', message: "${message}"
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true])
sh 'exit 1'
}
4 changes: 4 additions & 0 deletions common.bash
@@ -0,0 +1,4 @@
maintainer="my"
imagename="grouper"
version="2.3.0"
tomcat_version="6.0.35"
3 changes: 3 additions & 0 deletions conf/common.env
@@ -0,0 +1,3 @@
MYSQL_DATABASE=grouper
MYSQL_USER=grouper_user
MYSQL_PASSWORD=3cf0ccc7d6b240390188367933c9cd90
4 changes: 4 additions & 0 deletions conf/db.env
@@ -0,0 +1,4 @@
CREATE_NEW_DATABASE=1
MYSQL_ROOT_PASSWORD=123321
MYSQL_DATADIR=/var/lib/mysqlmounted
TERM=dumb
4 changes: 4 additions & 0 deletions conf/grouper.env
@@ -0,0 +1,4 @@
VERSION=2.3.0
TOMCAT_VERSION=6.0.35
GROUPER_SYSTEM_PASSWORD=3cf0ccc7d6b240390188367933c9cd90
MYSQL_HOST=mariadb
36 changes: 36 additions & 0 deletions conf/grouper.installer.properties
@@ -0,0 +1,36 @@
# this should be before the version number
download.server.url = http://software.internet2.edu/grouper
# default version to install
grouper.version = 2.3.0
# print out autorun keys in prompts so you can easily see how to configure the autorun
grouperInstaller.print.autorunKeys = true
# default to install or upgrade (default is install)
grouperInstaller.default.installOrUpgrade = install
# where to get grouper source from, the variable $BRANCH_NAME$ will be substituted for the branch
download.source.url = https://github.com/Internet2/grouper/archive/$BRANCH_NAME$.zip
# where to get grouper psp source from, the variable $BRANCH_NAME$ will be substituted for the branch
download.pspSource.url = https://github.com/Internet2/grouper-psp/archive/$BRANCH_NAME$.zip
##############################
## Autorun properties
##
## If you uncomment one of these properties it will be used as empty, only uncomment to use
##
##############################
#### set this to true to try to use defaults for everything. Only things without default values will need to be set
grouperInstaller.autorun.useDefaultsAsMuchAsAvailable = true
########## AUTORUN PROPERTIES WITH NO DEFAULT OR ARE COMMONLY CHANGED
## Note: not all of them need to be filled out for all operations
# autorun grouper system password (its not secure to have a plain text pass in a config file)
grouperInstaller.autorun.grouperSystemPassword = #GROUPER_SYSTEM_PASSWORD#
# autorun Enter the database URL
grouperInstaller.autorun.dbUrl = jdbc:mysql://#MYSQL_HOST#:3306/grouper
# autorun database user
grouperInstaller.autorun.dbUser = #MYSQL_USER#
# autorun database pass (note, it is not good security to have plaintext passwords in text config files)
grouperInstaller.autorun.dbPass = #MYSQL_PASSWORD#
# autorun Do you want to init the database (delete all existing grouper tables, add new ones) (t|f)?
grouperInstaller.autorun.deleteAndInitDatabase = t
# autorun What is the location of your tomcat server.xml for the UI?
# Note, if you dont use tomcat just leave it blank or type 'blank':
grouperInstaller.autorun.locationOfTomcatServerXml = /opt/grouper/2.3.0/apache-tomcat-6.0.35/conf/server.xml

11 changes: 11 additions & 0 deletions container_files/configure.sh
@@ -0,0 +1,11 @@
#!/bin/bash

sed -i "s|#GROUPER_SYSTEM_PASSWORD#|$GROUPER_SYSTEM_PASSWORD|g" /opt/grouper/2.3.0/grouper.installer.properties

sed -i "s|#MYSQL_HOST#|$MYSQL_HOST|g" /opt/grouper/2.3.0/grouper.installer.properties

sed -i "s|#MYSQL_USER#|$MYSQL_USER|g" /opt/grouper/2.3.0/grouper.installer.properties

sed -i "s|#MYSQL_PASSWORD#|$MYSQL_PASSWORD|g" /opt/grouper/2.3.0/grouper.installer.properties

cat /opt/grouper/2.3.0/grouper.installer.properties
46 changes: 46 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,46 @@
version: '2'

services:
db:
image: bigfleet/mariadb
container_name: mariadb
hostname: mariadb
networks:
- i2network
ports:
- "3306:3306"
cap_add:
- ALL
- NET_ADMIN
- SYS_ADMIN
volumes:
- ./mysql:/var/lib/mysqlmounted
env_file:
- conf/common.env
- conf/db.env

grouper:
image: my/grouper
container_name: grouper
hostname: grouper
depends_on:
- db
networks:
- i2network
ports:
- "80:80"
- "443:443"
cap_add:
- ALL
- NET_ADMIN
- SYS_ADMIN
volumes:
- logs:/opt/grouper/2.3.0/apache-tomcat-6.0.35/logs
env_file:
- conf/common.env
- conf/grouper.env

networks:
i2network:
driver: bridge

0 comments on commit 3aebcd3

Please sign in to comment.