Skip to content

Commit

Permalink
Merge pull request #10 from GRIDAPPSD/releases/2019.03.0
Browse files Browse the repository at this point in the history
2019.03.0 release
  • Loading branch information
tonya1 authored Mar 28, 2019
2 parents ec9af0d + be0a126 commit 77285fc
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# make use of vm's
sudo: 'required'

# have the docker service set up (we'll
# update it later)
services:
- 'docker'

# prepare the machine before any code
# installation scripts
before_install:
- './.travis/main.sh'

script:
- './.travis/build-docker.sh'
70 changes: 70 additions & 0 deletions .travis/build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

TAG="${TRAVIS_BRANCH//\//_}"

ORG=`echo $DOCKER_PROJECT | tr '[:upper:]' '[:lower:]'`
ORG="${ORG:+${ORG}/}"
IMAGE="${ORG}sample_app"
TIMESTAMP=`date +'%y%m%d%H'`
GITHASH=`git log -1 --pretty=format:"%h"`

BUILD_VERSION="${TIMESTAMP}_${GITHASH}${TRAVIS_BRANCH:+:$TRAVIS_BRANCH}"
echo "BUILD_VERSION $BUILD_VERSION"

# Pass gridappsd tag to docker-compose
docker build --build-arg TIMESTAMP="${BUILD_VERSION}" -t ${IMAGE}:${TIMESTAMP}_${GITHASH} .
status=$?
if [ $status -ne 0 ]; then
echo "Error: status $status"
exit 1
fi

# To have `DOCKER_USERNAME` and `DOCKER_PASSWORD`
# filled you need to either use `travis`' cli
# (https://github.com/travis-ci/travis.rb)
# and then `travis set ..` or go to the travis
# page of your repository and then change the
# environment in the settings pannel.

if [ -n "$DOCKER_USERNAME" -a -n "$DOCKER_PASSWORD" ]; then

echo " "
echo "Connecting to docker"

echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
status=$?
if [ $status -ne 0 ]; then
echo "Error: status $status"
exit 1
fi

if [ -n "$TAG" -a -n "$ORG" ]; then
# Get the built container name
CONTAINER=`docker images --format "{{.Repository}}:{{.Tag}}" ${IMAGE}`

echo "docker push ${CONTAINER}"
docker push "${CONTAINER}"
status=$?
if [ $status -ne 0 ]; then
echo "Error: status $status"
exit 1
fi

echo "docker tag ${CONTAINER} ${IMAGE}:$TAG"
docker tag ${CONTAINER} ${IMAGE}:$TAG
status=$?
if [ $status -ne 0 ]; then
echo "Error: status $status"
exit 1
fi

echo "docker push ${IMAGE}:$TAG"
docker push ${IMAGE}:$TAG
status=$?
if [ $status -ne 0 ]; then
echo "Error: status $status"
exit 1
fi
fi

fi
62 changes: 62 additions & 0 deletions .travis/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# Set an option to exit immediately if any error appears
set -o errexit

# Main function that describes the behavior of the
# script.
# By making it a function we can place our methods
# below and have the main execution described in a
# concise way via function invocations.
main() {
setup_dependencies
update_docker_configuration

echo "SUCCESS:
Done! Finished setting up Travis machine.
"
}

# Prepare the dependencies that the machine need.
# Here I'm just updating the apt references and then
# installing both python and python-pip. This allows
# us to make use of `pip` to fetch the latest `docker-compose`
# later.
# We also upgrade `docker-ce` so that we can get the
# latest docker version which allows us to perform
# image squashing as well as multi-stage builds.
setup_dependencies() {
echo "INFO:
Setting up dependencies.
"

sudo apt update -y
sudo apt install realpath -y
#python python-pip -y
sudo apt install --only-upgrade docker-ce -y

sudo pip install docker-compose || true

docker info
docker-compose --version
}

# Tweak the daemon configuration so that we
# can make use of experimental features (like image
# squashing) as well as have a bigger amount of
# concurrent downloads and uploads.
update_docker_configuration() {
echo "INFO:
Updating docker configuration
"

echo '{
"experimental": true,
"storage-driver": "overlay2",
"max-concurrent-downloads": 50,
"max-concurrent-uploads": 50
}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
}

main
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# from the gridappsd container.
FROM gridappsd/app-container-base

# Add the TIMESTAMP variable to capture the build information from
# the travis docker build command and add them to the image.
ARG TIMESTAMP
RUN echo $TIMESTAMP > /dockerbuildversion.txt

# Pick a spot to put our application code
# (note gridappsd-python is located at /usr/src/gridappsd-python)
# and is already installed in the app-container-base environment.
Expand Down

0 comments on commit 77285fc

Please sign in to comment.