Skip to content
Snippets Groups Projects
Commit 84d0afc8 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #1275 from metabase/docker_and_eb_release_scripts

Docker and EB release scripts
parents f1db6dfa d5928185
No related branches found
No related tags found
No related merge requests found
......@@ -35,3 +35,4 @@ OSX/build
/osx-artifacts
OSX/dsa_priv.pem
bin/config.json
bin/release/aws-eb/metabase-aws-eb.zip
option_settings:
- namespace: aws:elasticbeanstalk:command
option_name: Timeout
value: 600
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "metabase/metabase:@@MB_TAG@@",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "3000"
}
],
"Logging": "/var/log/metabase"
}
#!/bin/bash
BASEDIR=$(dirname $0)
CURRENTDIR=$PWD
S3_BUCKET=downloads.metabase.com
# parse any cmd line arguments
while [[ $# > 0 ]]
do
key="$1"
case $key in
--publish)
PUBLISH=YES
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
if [ "$PUBLISH" == "YES" ] && [ -z "$AWS_DEFAULT_PROFILE" ]; then
echo "In order to publish an Elastic Beanstalk version to S3 you must set the AWS_DEFAULT_PROFILE environment variable"
exit 1
fi
# we need to know the tag of the current repo, and if we can't get a tag then bail
MB_TAG=`${BASEDIR}/../current_tag.sh`
if [ $? -eq 1 ]; then
echo "Failed to get current tag from git. Make sure you are on a tagged commit!"
exit 1
fi
EB_FILE=metabase-aws-eb.zip
S3_FILE=s3://${S3_BUCKET}/${MB_TAG}/${EB_FILE}
echo "Building Elastic Beanstalk app version from Metabase ${MB_TAG}"
# dynamically insert our MB version into the EB config file
sed "s/@@MB_TAG@@/${MB_TAG}/" < ${BASEDIR}/Dockerrun.aws.json.template > ${BASEDIR}/Dockerrun.aws.json
# create our EB zip file
cd $BASEDIR; zip -r ${EB_FILE} .ebextensions Dockerrun.aws.json; cd $CURRENTDIR
# clean up the temporary Dockerrun.aws.json file we created
rm ${BASEDIR}/Dockerrun.aws.json
if [ "$PUBLISH" == "YES" ]; then
echo "Publishing EB file to S3 at ${S3_FILE}"
# s3 put
aws s3 cp ${BASEDIR}/${EB_FILE} ${S3_FILE}
# TODO: quick check to see that we succeeded
fi
echo "Done"
#!/bin/bash
# use git to tell us what tag we are on
# NOTE: if we happen to NOT be on a tagged commit this will be "undefined"
MB_TAG=$(git name-rev --tags --name-only HEAD)
# this strips off the ^0 that ends up on the end of our tag when we grab it
MB_TAG=${MB_TAG%^0}
# if we didn't get a tag then consider this a failed execution and respond with exit code 1
if [ "$MB_TAG" == "undefined" -o $? -eq 1 ]; then
exit 1
fi
echo $MB_TAG
FROM java:openjdk-7-jre
ENV LC_ALL C
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
# add Metabase jar
COPY ./metabase.jar /app/
# add our run script to the image
COPY ./run_metabase.sh /app/
RUN chmod 755 /app/run_metabase.sh
# expose our default runtime port
EXPOSE 3000
# run it
ENTRYPOINT ["/app/run_metabase.sh"]
#!/bin/bash
BASEDIR=$(dirname $0)
DOCKERHUB_NAMESPACE=metabase
DOCKERHUB_REPOSITORY=metabase
# parse any cmd line arguments
while [[ $# > 0 ]]
do
key="$1"
case $key in
--publish)
PUBLISH=YES
;;
--latest)
LATEST=YES
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
if [ "$PUBLISH" == "YES" ] && [ -z "$DOCKERHUB_EMAIL" -o -z "$DOCKERHUB_USERNAME" -o -z "$DOCKERHUB_PASSWORD" ]; then
echo "In order to publish an image to Dockerhub you must set \$DOCKERHUB_EMAIL, \$DOCKERHUB_USERNAME and \$DOCKERHUB_PASSWORD before running."
exit 1
fi
# we need to know the tag of the current repo, and if we can't get a tag then bail
MB_TAG=`${BASEDIR}/../current_tag.sh`
if [ $? -eq 1 ]; then
echo "Failed to get current tag from git. Make sure you are on a tagged commit!"
exit 1
fi
# TODO: verify we have access to docker cmd and minimum version?
echo "Building Docker image ${DOCKERHUB_NAMESPACE}/${DOCKERHUB_REPOSITORY}:${MB_TAG} from Metabase ${MB_TAG}"
# download the official version of Metabase which matches our tag
curl -o ${BASEDIR}/metabase.jar http://downloads.metabase.com/${MB_TAG}/metabase.jar
# TODO: verify the download
# now tell docker to build our image
# TODO: —-no-cache=true
docker build -t ${DOCKERHUB_NAMESPACE}/${DOCKERHUB_REPOSITORY}:${MB_TAG} $BASEDIR
# TODO: validate our built docker image
if [ "$PUBLISH" == "YES" ]; then
echo "Publishing image ${DOCKERHUB_NAMESPACE}/${DOCKERHUB_REPOSITORY}:${MB_TAG} to Dockerhub"
# make sure that we are logged into dockerhub
docker login --email="${DOCKERHUB_EMAIL}" --username="${DOCKERHUB_USERNAME}" --password="${DOCKERHUB_PASSWORD}"
# push the built image to dockerhub
docker push ${DOCKERHUB_NAMESPACE}/${DOCKERHUB_REPOSITORY}:${MB_TAG}
# TODO: quick check against dockerhub to see that our new image made it
if [ "$LATEST" == "YES" ]; then
# tag our recent versioned image as "latest"
docker tag -f ${DOCKERHUB_NAMESPACE}/${DOCKERHUB_REPOSITORY}:${MB_TAG} ${DOCKERHUB_NAMESPACE}/${DOCKERHUB_REPOSITORY}:latest
# then push it as well
docker push ${DOCKERHUB_NAMESPACE}/${DOCKERHUB_REPOSITORY}:latest
# TODO: validate push succeeded
fi
fi
# TODO: cleanup after ourselves and remove the Metabase binary we downloaded
rm -f ${BASEDIR}/metabase.jar
echo "Done"
#!/bin/bash
# if nobody manually set a host to list on then go with $HOSTNAME
if [ -z "$MB_JETTY_HOST" ]; then
export MB_JETTY_HOST=$HOSTNAME
fi
# Metabase Database Info - this is just about what db the Metabase application uses for internal storage
# AWS Elastic Beanstalk w/ RDS
if [ ! -z "$RDS_HOSTNAME" ]; then
# EEK: this is a bit fragile. if user picks a non-standard port for their db we are screwed :(
if [ "$MB_DB_PORT" == "3306" ]; then
export MB_DB_TYPE=mysql
else
export MB_DB_TYPE=postgres
fi
export MB_DB_DBNAME=$RDS_DB_NAME
export MB_DB_USER=$RDS_USERNAME
export MB_DB_PASS=$RDS_PASSWORD
export MB_DB_HOST=$RDS_HOSTNAME
export MB_DB_PORT=$RDS_PORT
fi
# Launch the application
java -Dlogfile.path=target/log -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -jar /app/metabase.jar
......@@ -44,7 +44,7 @@ When your environment type settings look like the above then go ahead and click
The application version describes the exact binary you wish to deploy to your Elastic Beanstalk application. Metabase provides a pre-built AWS Elastic Beanstalk application version which can be linked to directly. Simply enter the following url in the `S3 URL` textbox:
https://s3.amazonaws.com/downloads.metabase.com/v0.12.0/aws-elastic-beanstalk.zip
https://s3.amazonaws.com/downloads.metabase.com/v0.12.0/metabase-aws-eb.zip
Leave all the settings under Deployment Limits on their defaults. These settings won't impact Metabase.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment