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

tidy up and consolidate all of our aws-eb scripts. remove unneeded release/dockerhub scripts.

parent daa71631
Branches
Tags
No related merge requests found
......@@ -2,7 +2,6 @@
BASEDIR=$(dirname $0)
CURRENTDIR=$PWD
PROJECT_ROOT=$(cd ${BASEDIR}/../../..; pwd)
DOCKERHUB_REPO=metabase
S3_BUCKET=downloads.metabase.com
......@@ -27,7 +26,7 @@ S3_FILE=s3://${S3_BUCKET}/${MB_TAG}/metabase-aws-eb.zip
S3_LAUNCH_FILE=s3://${S3_BUCKET}/${MB_TAG}/${EB_LAUNCH_FILE}
# make the release file
${PROJECT_ROOT}/bin/aws-eb-docker/build-eb-version.sh ${MB_TAG} ${DOCKERHUB_REPO}
${BASEDIR}/build-eb-version.sh ${MB_TAG} ${DOCKERHUB_REPO}
# dynamically insert our MB version into the EB launch file
sed "s/@@MB_TAG@@/${MB_TAG}/" < ${BASEDIR}/${EB_LAUNCH_FILE}.template > ${BASEDIR}/${EB_LAUNCH_FILE}
......
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment