diff --git a/app.json b/app.json index f23b28cda806a04fe09c67f63ebffd50c939cadd..bcfe0549507758cb235654dc9964e67627345989 100644 --- a/app.json +++ b/app.json @@ -11,15 +11,14 @@ "repository": "https://github.com/metabase/metabase", "logo": "https://avatars3.githubusercontent.com/u/10520629?v=3&s=200", "success_url": "/setup", - "buildpacks": [ - { - "url": "https://github.com/heroku/heroku-buildpack-nodejs" - }, - { - "url": "https://github.com/heroku/heroku-buildpack-clojure" - } - ], "env": { - "NPM_CONFIG_LOGLEVEL": "info" - } + }, + "addons": [ + "heroku-postgresql", + "mailgun" + ], + "buildpacks": [ + { "url": "https://github.com/heroku/heroku-buildpack-nodejs" }, + { "url": "https://github.com/heroku/heroku-buildpack-clojure" } + ] } diff --git a/bin/deploy-metabase-deploy b/bin/deploy-metabase-deploy new file mode 100755 index 0000000000000000000000000000000000000000..d25134aa70fcea85b3eadac17ec12135bed62b61 --- /dev/null +++ b/bin/deploy-metabase-deploy @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -eu +set -o pipefail + +SRC_DIR="$PWD" +DEPLOY_DIR="$PWD/.metabase_deploy" + +if [ "$#" -gt 0 ]; then + DEPLOY_TAG="$1" +else + DEPLOY_TAG="$(./bin/version | tr ' ' '_')" +fi + +DEPLOY_REPO="git@github.com:metabase/metabase-deploy.git" +DEPLOY_REPO_SLUG="$(echo "$DEPLOY_REPO" | grep -Eo "[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+")" +DEPLOY_TREE="$DEPLOY_REPO_SLUG/tree/$DEPLOY_TAG" + +# build the app +./bin/build + +# clone the metabase-deploy repo +git clone "$DEPLOY_REPO" "$DEPLOY_DIR" + +# copy required files over +FILES="Procfile app.json bin/start target/uberjar/metabase-standalone.jar" +for FILE in $FILES; do + mkdir -p "$DEPLOY_DIR/$(dirname $FILE)" + cp "$FILE" "$DEPLOY_DIR/$FILE" +done + +# change to the deploy directory +cd "$DEPLOY_DIR" + +# modify app.json to use null-buildpack since we're using a pre-compiled jar +node <<EOF +var fs = require("fs"); +var app = JSON.parse(fs.readFileSync("app.json")); +app.buildpacks = [{ "url": "http://github.com/ryandotsmith/null-buildpack.git" }]; +delete app.env.NPM_CONFIG_LOGLEVEL; +fs.writeFileSync("app.json", JSON.stringify(app, null, 2)); +EOF + +# generate a README +cat > README.md <<EOF +[](https://heroku.com/deploy?template=https://github.com/$DEPLOY_TREE) +EOF + +# add, commit, tag, and push +git add . +git commit -m "Deploy $DEPLOY_TAG" +git tag "$DEPLOY_TAG" +git push --tags "$DEPLOY_REPO" master + +# change back +cd "$SRC_DIR" + +# pretend like this never happened +rm -rf "$DEPLOY_DIR"