Skip to content
Snippets Groups Projects
Commit 65123016 authored by Cam Saul's avatar Cam Saul
Browse files

Merge release-x.37.x into master 11/04/2020

parents 7bcd3436 f285ae89
No related branches found
No related tags found
No related merge requests found
Showing
with 174 additions and 413 deletions
# Example Dockerfile for creating Docker images which includes an H2 database
# (./h2dump.db) from which to initialize the Metabase database. It can be used
# to create Docker images for Elastic Beanstalk apps.
FROM metabase/metabase
COPY ./h2dump.db /app/initial.mv.db
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "metabase/@@MB_REPOSITORY@@:@@MB_TAG@@",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "3000"
}
],
"Logging": "/var/log/metabase"
}
#!/bin/bash
BASEDIR=$(dirname $0)
source "$BASEDIR/functions"
MB_TAG=$1
if [ -z $MB_TAG ]; then
echo "usage: $0 <release-name> <docker-repository>"
exit 1
fi
MB_DOCKER_REPOSITORY=$2
if [ -z $MB_DOCKER_REPOSITORY ]; then
echo "usage: $0 <release-name> <docker-repository>"
exit 1
fi
make_eb_version ${MB_TAG} ${MB_DOCKER_REPOSITORY}
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Deploys Metabase by creating an ElasticBeanstalk application in an contained in a CloudFormation stack.",
"Parameters": {
"MetabaseVersion": {
"Description": "Metabase Version",
"Type": "String",
"Default": "@@MB_TAG@@"
},
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the AWS Elastic Beanstalk instance",
"Type": "AWS::EC2::KeyPair::KeyName"
},
"instanceType": {
"Description": "The Type of EC2 instance to use for running Metabase",
"Type": "String",
"Default": "t2.small"
},
"VPCid": {
"Description": "The VPC to use for running Metabase",
"Type": "AWS::EC2::VPC::Id"
},
"Subnets": {
"Description": "The VPC subnet(s) to use for running Metabase",
"Type": "List<AWS::EC2::Subnet::Id>"
}
},
"Resources": {
"metabaseApplication": {
"Type": "AWS::ElasticBeanstalk::Application",
"Properties": {
"Description": "Metabase Application",
"ApplicationVersions": [
{
"VersionLabel": {
"Ref": "MetabaseVersion"
},
"Description": "Metabase Application Version",
"SourceBundle": {
"S3Bucket": "downloads.metabase.com",
"S3Key": {
"Fn::Join": [
"/",
[
{
"Ref": "MetabaseVersion"
},
"metabase-aws-eb.zip"
]
]
}
}
}
],
"ConfigurationTemplates": [
{
"TemplateName": "MetabaseConfiguration",
"Description": "Metabase Application Configuration",
"SolutionStackName": "64bit Amazon Linux 2017.03 v2.7.0 running Docker 17.03.1-ce",
"OptionSettings": [
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "EC2KeyName",
"Value": {
"Ref": "KeyName"
}
},
{
"Namespace": "aws:rds:dbinstance",
"OptionName": "DBEngine",
"Value": "postgres"
},
{
"Namespace": "aws:rds:dbinstance",
"OptionName": "DBAllocatedStorage",
"Value": "10"
},
{
"Namespace": "aws:rds:dbinstance",
"OptionName": "DBInstanceClass",
"Value": "db.t2.small"
},
{
"Namespace": "aws:rds:dbinstance",
"OptionName": "MultiAZDatabase",
"Value": "false"
},
{
"Namespace": "aws:rds:dbinstance",
"OptionName": "DBDeletionPolicy",
"Value": "Snapshot"
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "InstanceType",
"Value": {
"Ref": "instanceType"
}
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "VPCId",
"Value": {
"Ref": "VPCid"
}
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "Subnets",
"Value": {
"Fn::Join": [
",",
{
"Ref": "Subnets"
}
]
}
}
]
}
]
}
},
"metabaseEnvironment": {
"Type": "AWS::ElasticBeanstalk::Environment",
"Properties": {
"ApplicationName": {
"Ref": "metabaseApplication"
},
"Description": "AWS Elastic Beanstalk Environment for Metabase",
"TemplateName": "MetabaseConfiguration",
"VersionLabel": {
"Ref": "MetabaseVersion"
}
}
}
},
"Outputs": {
"URL": {
"Description": "Metabase URL",
"Value": {
"Fn::GetAtt": [
"metabaseEnvironment",
"EndpointURL"
]
}
}
}
}
#!/bin/bash
BASEDIR=$(dirname $0)
source "$BASEDIR/functions"
MB_TAG=$1
if [ -z $MB_TAG ]; then
echo "usage: $0 <release-name> <docker-repository> <eb-environment>"
exit 1
fi
MB_DOCKER_REPOSITORY=$2
if [ -z $MB_DOCKER_REPOSITORY ]; then
echo "usage: $0 <release-name> <docker-repository> <eb-environment>"
exit 1
fi
EB_ENVIRONMENT=$3
if [ -z $EB_ENVIRONMENT ]; then
echo "usage: $0 <release-name> <docker-repository> <eb-environment>"
exit 1
fi
if [ -z "$AWS_DEFAULT_PROFILE" ]; then
echo "You must set the AWS_DEFAULT_PROFILE environment variable in order to deploy to AWS!"
exit 1
fi
make_eb_version ${MB_TAG} ${MB_DOCKER_REPOSITORY}
upload_eb_version ${MB_TAG}
create_eb_version ${MB_TAG}
deploy_version ${MB_TAG} ${EB_ENVIRONMENT}
#!/bin/bash
set -eo pipefail
BASEDIR=$(dirname $0)
CURRENTDIR=$PWD
PROJECT_ROOT=$(cd ${BASEDIR}/..; pwd)
ARTIFACTS_S3BUCKET=${S3BUCKET:=metabase-artifacts}
export LANG=en_US.UTF-8
export LANGUAGE=$LANG
export LC_ALL=$LANG
CF_TEMPLATE=cloudformation-elasticbeanstalk.json
CF_TEMPLATE_PATH=/tmp/$CF_TEMPLATE
S3_CF_TEMPLATE_PATH=s3://$ARTIFACTS_S3BUCKET/eb/$CF_TEMPLATE
make_eb_version() {
MB_TAG=$1
MB_DOCKER_REPOSITORY=$2
$(which locale) | $(which sort) || true
if [[ -z $MB_TAG ]]; then
echo "release name not provided!"
exit 1
fi
if [[ -z $MB_DOCKER_REPOSITORY ]]; then
echo "docker repository name not provided!"
exit 1
fi
RELEASE_FILE="/tmp/${MB_TAG}.zip"
echo "Building Elastic Beanstalk app version for Metabase using Docker Image: metabase/${MB_DOCKER_REPOSITORY}:${MB_TAG}"
# dynamically insert our MB version into the EB config file
sed "s/@@MB_REPOSITORY@@/${MB_DOCKER_REPOSITORY}/" < ${BASEDIR}/Dockerrun.aws.json.template > ${BASEDIR}/Dockerrun.aws.json.tmp
sed "s/@@MB_TAG@@/${MB_TAG}/" < ${BASEDIR}/Dockerrun.aws.json.tmp > ${BASEDIR}/Dockerrun.aws.json
# set the default version in the cloudformation template from the template-template (yo dawg i heard you like templates ;)
sed "s/@@MB_TAG@@/${MB_TAG}/" < ${BASEDIR}/$CF_TEMPLATE.template > $CF_TEMPLATE_PATH
# create our EB zip file
cd $BASEDIR; zip -r ${RELEASE_FILE} .ebextensions Dockerrun.aws.json; cd $CURRENTDIR
# clean up the temporary Dockerrun.aws.json file we created
rm ${BASEDIR}/Dockerrun.aws.json.tmp
rm ${BASEDIR}/Dockerrun.aws.json
}
upload_eb_version() {
MB_TAG=$1
$(which locale) | $(which sort) || true
if [[ -z $MB_TAG ]]; then
echo "release name not provided!"
exit 1
fi
echo "uploading /tmp/${MB_TAG}.zip -> $ARTIFACTS_S3BUCKET/eb/"
aws s3 cp /tmp/${MB_TAG}.zip s3://$ARTIFACTS_S3BUCKET/eb/${MB_TAG}.zip
echo "uploading $CF_TEMPLATE_PATH -> $S3_CF_TEMPLATE_PATH"
aws s3 cp $CF_TEMPLATE_PATH $S3_CF_TEMPLATE_PATH
}
create_eb_version() {
EB_APPLICATION=Metabase
MB_TAG=$1
$(which locale) | $(which sort) || true
if [[ -z $MB_TAG ]]; then
echo "release name not provided!"
exit 1
fi
echo "Creating app version in EB"
aws elasticbeanstalk create-application-version --no-auto-create-application --region us-east-1 --application-name ${EB_APPLICATION} --version-label ${MB_TAG} --source-bundle S3Bucket="${ARTIFACTS_S3BUCKET}",S3Key="eb/${MB_TAG}.zip"
}
deploy_version() {
MB_TAG=$1
EB_ENVIRONMENT=$2
$(which locale) | $(which sort) || true
if [[ -z $MB_TAG ]]; then
echo "release name not provided!"
exit 1
fi
if [[ -z $EB_ENVIRONMENT ]]; then
echo "beanstalk environment not provided!"
exit 1
fi
aws elasticbeanstalk update-environment --region us-east-1 --environment-name ${EB_ENVIRONMENT} --version-label ${MB_TAG}
}
<!DOCTYPE html>
<meta charset=utf-8>
<title>Redirecting...</title>
<link rel=canonical href="https://console.aws.amazon.com/elasticbeanstalk/home?region=us-east-1#/newApplication?applicationName=Metabase&tierName=WebServer&platform=Docker&sourceBundleUrl=https%3A%2F%2Fdownloads.metabase.com.s3.amazonaws.com%2F@@MB_TAG@@%2Fmetabase-aws-eb.zip&instanceType=t2.small&withRds=true&rdsDBEngine=postgres&rdsDBAllocatedStorage=10&rdsDBInstanceClass=db.t2.small&rdsMultiAZDatabase=false&rdsDBDeletionPolicy=Snapshot">
<meta http-equiv=refresh content="0; url=https://console.aws.amazon.com/elasticbeanstalk/home?region=us-east-1#/newApplication?applicationName=Metabase&tierName=WebServer&platform=Docker&sourceBundleUrl=https%3A%2F%2Fdownloads.metabase.com.s3.amazonaws.com%2F@@MB_TAG@@%2Fmetabase-aws-eb.zip&instanceType=t2.small&withRds=true&rdsDBEngine=postgres&rdsDBAllocatedStorage=10&rdsDBInstanceClass=db.t2.small&rdsMultiAZDatabase=false&rdsDBDeletionPolicy=Snapshot">
<h1>Redirecting...</h1>
<a href="https://console.aws.amazon.com/elasticbeanstalk/home?region=us-east-1#/newApplication?applicationName=Metabase&tierName=WebServer&platform=Docker&sourceBundleUrl=https%3A%2F%2Fdownloads.metabase.com.s3.amazonaws.com%2F@@MB_TAG@@%2Fmetabase-aws-eb.zip&instanceType=t2.small&withRds=true&rdsDBEngine=postgres&rdsDBAllocatedStorage=10&rdsDBInstanceClass=db.t2.small&rdsMultiAZDatabase=false&rdsDBDeletionPolicy=Snapshot">Click here if you are not redirected.</a>
<script>location='https://console.aws.amazon.com/elasticbeanstalk/home?region=us-east-1#/newApplication?applicationName=Metabase&tierName=WebServer&platform=Docker&sourceBundleUrl=https%3A%2F%2Fdownloads.metabase.com.s3.amazonaws.com%2F@@MB_TAG@@%2Fmetabase-aws-eb.zip&instanceType=t2.small&withRds=true&rdsDBEngine=postgres&rdsDBAllocatedStorage=10&rdsDBInstanceClass=db.t2.small&rdsMultiAZDatabase=false&rdsDBDeletionPolicy=Snapshot'</script>
#!/bin/bash
BASEDIR=$(dirname $0)
CURRENTDIR=$PWD
if [ "$MB_EDITION" = "ENTERPRISE" ]; then
DOCKERHUB_REPO=metabase-enterprise
else
DOCKERHUB_REPO=metabase
fi
S3_BUCKET=downloads.metabase.com
# parse any cmd line arguments
MB_TAG=$1
if [ -z $MB_TAG ]; then
echo "usage: $0 <release-name> [--publish]"
exit 1
fi
if [ -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
# TODO: improve this (hard coding)
EB_FILE=/tmp/${MB_TAG}.zip
EB_LAUNCH_FILE=launch-aws-eb.html
S3_FILE=s3://${S3_BUCKET}/enterprise/${MB_TAG}/metabase-aws-eb.zip
S3_LAUNCH_FILE=s3://${S3_BUCKET}/enterprise/${MB_TAG}/${EB_LAUNCH_FILE}
# make the release file
${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}
echo "Publishing EB files to S3 at ${S3_FILE} and ${S3_LAUNCH_FILE}"
# s3 put
aws s3 cp ${EB_FILE} ${S3_FILE}
aws s3 cp ${BASEDIR}/${EB_LAUNCH_FILE} ${S3_LAUNCH_FILE}
# TODO: quick check to see that we succeeded
# clean up the temporary EB launch file we created
rm ${BASEDIR}/${EB_LAUNCH_FILE}
echo "Done"
......@@ -4,9 +4,14 @@ set -e
MB_EDITION=${MB_EDITION:=oss}
if [ "$MB_EDITION" != ee ] && [ "$MB_EDITION" != oss ]; then
echo "MB_EDITION must be either 'ee' or 'oss'."
exit 1
fi
# Generate the resources/version.properties file
version() {
VERSION_INFO=$(./bin/version $MB_EDITION)
VERSION_INFO=$(./bin/version)
IFS=', ' read -a info <<< ${VERSION_INFO}
echo "Tagging uberjar with version '$VERSION_INFO'..."
......@@ -51,13 +56,8 @@ drivers() {
uberjar() {
lein clean
if [ "$MB_EDITION" = "ENTERPRISE" ]; then
echo "Running 'lein with-profile +ee uberjar'..."
lein with-profile +ee uberjar
else
echo "Running 'lein uberjar'..."
lein uberjar
fi
echo "Running 'lein with-profile +$MB_EDITION uberjar'..."
lein with-profile +$MB_EDITION uberjar
}
all() {
......
......@@ -7,6 +7,10 @@ PROJECT_ROOT="$BASEDIR/../.."
DOCKERHUB_NAMESPACE=metabase
if [ ! -z "$MB_EDITION" ] && [ "$MB_EDITION" != ee ] && [ "$MB_EDITION" != oss ]; then
echo "MB_EDITION must be either 'ee' or 'oss'."
exit 1
fi
BUILD_TYPE=$1
if [ -z $BUILD_TYPE ]; then
......@@ -37,7 +41,7 @@ fi
if [ "$BUILD_TYPE" == "release" ]; then
if [ "$MB_EDITION" = "ENTERPRISE" ]; then
if [ "$MB_EDITION" = ee ]; then
DOCKERHUB_REPO=metabase-enterprise
else
DOCKERHUB_REPO=metabase
......
......@@ -35,6 +35,7 @@
copy-file!
create-directory-unless-exists!
delete-file!
delete-file-if-exists!
file-exists?
filename
find-files]
......
......@@ -23,15 +23,17 @@
(str filename))
(defn create-directory-unless-exists! [^String dir]
(when-not (file-exists? dir)
(steps/step (format "Creating directory %s..." dir)
(.mkdirs (File. dir))))
(steps/step (format "Create directory %s if it does not exist" dir)
(if (file-exists? dir)
(out/announce "%s already exists." dir)
(steps/step (format "Create directory %s" dir)
(.mkdirs (File. dir)))))
dir)
(defn delete-file!
(defn delete-file-if-exists!
"Delete a file or directory (recursively) if it exists."
([^String filename]
(steps/step (format "Deleting %s..." filename)
(steps/step (format "Delete %s if exists" filename)
(if (file-exists? filename)
(let [file (File. filename)]
(if (.isDirectory file)
......@@ -42,7 +44,13 @@
(assert (not (file-exists? filename)))))
([file & more]
(dorun (map delete-file! (cons file more)))))
(dorun (map delete-file-if-exists! (cons file more)))))
(defn ^:deprecated delete-file!
"Alias for `delete-file-if-exists!`. Here for backwards compatibility. Prefer `delete-file-if-exists!` going
forward."
[& args]
(apply delete-file-if-exists! args))
(defn copy-file!
"Copy a `source` file (or directory, recursively) to `dest`."
......
......@@ -4,7 +4,7 @@
[metabuild-common.core :as u]))
(def ^:private required-commands
["git" "node" "yarn" "aws" "docker" "java" "wget" "shasum" "gettext"])
["git" "node" "yarn" "aws" "docker" "java" "wget" "shasum" "gettext" "zip"])
(defn- check-for-required-commands []
(u/step "Verify required external commands are available"
......
......@@ -7,12 +7,14 @@
(assert (str/ends-with? (env/env :user-dir) "/bin/release")
"Please run release.clj from the `release` directory e.g. `cd bin/release; clojure -m release`")
(def cloudfront-distribution-id "E35CJLWZIZVG7K")
(def ^String root-directory
"e.g. /Users/cam/metabase"
(.. (File. (env/env :user-dir)) getParentFile getParent))
(.. (File. ^String (env/env :user-dir)) getParentFile getParent))
(def ^String uberjar-path
(str root-directory "/target/uberjar/metabase.jar"))
(u/filename root-directory "target" "uberjar" "metabase.jar"))
(defonce ^:private build-options
(atom nil))
......@@ -83,10 +85,10 @@
(defn artifact-download-url
"Public-facing URL where you can download the artifact after it has been uploaded."
([filename]
(^String [filename]
(artifact-download-url (version) filename))
([version filename]
(^String [version filename]
(format "https://%s/%s/%s"
(downloads-url)
(if (= version "latest") "latest" (str "v" version))
......@@ -102,10 +104,36 @@
:ce "metabase/metabase-buildpack"
nil))
(defn metabase-repo []
(case (edition)
:ce "metabase/metabase"
:ee "metabase/metabase-enterprise"))
(defn metabase-repo
"Metabase GitHub repo"
[]
"metabase/metabase")
(defn docker-tag []
(defn docker-tag
"The complete image name + tag e.g. \"metabase/metabase:v0.37.0\""
[]
(format "%s:v%s" (docker-image-name) (version)))
(defn s3-artifact-path
"S3 path excluding the protocol and bucket e.g. `/enterprise/v1.37.0.2/metabase.jar`"
([filename]
(s3-artifact-path (version) filename))
([version filename]
(str
(when (= (edition) :ee)
"/enterprise")
(format "/%s/%s"
(if (= version "latest") "latest" (str "v" version))
filename))))
(defn s3-artifact-url
"S3 path including protocol and bucket e.g. `s3://downloads.metabase.com/enterprise/v1.37.0.2/metabase.jar`"
([filename]
(s3-artifact-url (version) filename))
([version filename]
(s3-artifact-url "downloads.metabase.com" version filename))
([s3-bucket version filename]
(format "s3://%s%s" s3-bucket (s3-artifact-path version filename))))
(ns release.common.upload
(:require [release.common :as c]))
(defn upload-artifact!
"Upload an artifact to downloads.metabase.com and create a CloudFront invalidation."
([source-file filename]
(upload-artifact! source-file (c/version) filename))
([source-file version filename]
(u/step (format "Upload %s to %s" source-file (c/artifact-download-url version filename))
(u/s3-copy! (u/assert-file-exists source-file) (c/s3-artifact-url version filename))
(u/create-cloudfront-invalidation! c/cloudfront-distribution-id (c/s3-artifact-path version filename)))))
......@@ -10,6 +10,7 @@
(defn- validate-docker-image []
(u/step "Validate Docker image"
(u/announce "TODO")
;; image="$1"
;; docker pull "$image" > /dev/null
;; docker_hash=$(docker run --rm "$image" version | grep -Eo 'hash [0-9a-f]+' | awk '{ print $2 }')
......
......@@ -17,7 +17,7 @@
(u/step "Generate draft changelog"
(let [pre-release? (c/pre-release-version?)
{bugs :bug, enhancements :enhancement} (group-by github/issue-type (github/milestone-issues))]
(stencil/render-file (u/assert-file-exists "release-template.md")
(stencil/render-file (u/assert-file-exists "release/draft_release/release-template.md")
{:enhancements enhancements
:bug-fixes bugs
:docker-tag (c/docker-tag)
......
(ns release.elastic-beanstalk
"Code related to building and publishing Elastic Beanstalk artifacts."
(:require [metabuild-common.core :as u]
(:require [cheshire.core :as json]
[clojure.core.cache :as cache]
[metabuild-common.core :as u]
[release.common :as c]
[release.common.http :as common.http]))
[release.common
[http :as common.http]
[upload :as upload]]
[stencil loader
[core :as stencil]]))
;; Disable caching of our template files for easier REPL debugging, we're only rendering them once anyways
(stencil.loader/set-cache (cache/ttl-cache-factory {} :ttl 0))
;; create a ZIP file with the contents
;; metabase-aws-eb.zip
;; ├─ Dockerrun.aws.json
;; ├─ .ebextensions/
;; ├─ 01_metabase.config
;; ├─ metabase_config/
;; ├─ (a bunch of other stuff)
(def ^:private eb-extensions-source
"Source location of the .ebextensions directory"
(u/assert-file-exists (u/filename c/root-directory "bin" "release" "release" "elastic_beanstalk" ".ebextensions")))
(def ^:private archive-temp-dir
"Path where we'll put the contents of the ZIP file before we create it."
"/tmp/metabase-aws-eb")
(def ^:private archive-path "/tmp/metabase-aws-eb.zip")
(def ^:private html-file-path "/tmp/launch-aws-eb.html")
(defn- validate-json-docker-tag []
(u/step (format "Check that Dockerrun.aws.json Docker tag is %s" (c/docker-tag))
(u/step "Download archive"
(u/delete-file-if-exists! archive-path)
(u/sh {:quiet? true} "wget" "--quiet" "--no-cache" "--output-document" archive-path
(c/artifact-download-url "metabase-aws-eb.zip")))
(u/step "Unzip archive"
(u/delete-file-if-exists! archive-temp-dir)
(u/sh "unzip" (u/assert-file-exists archive-path) "-d" archive-temp-dir))
(u/step "Validate JSON file"
(let [json (-> (u/assert-file-exists (u/filename (u/assert-file-exists archive-temp-dir) "Dockerrun.aws.json"))
slurp
(json/parse-string true))
tag (get-in json [:Image :Name])]
(u/announce "Docker tag is %s" tag)
(when-not (= tag (c/docker-tag))
(throw (ex-info "Incorrect Docker tag." {:expected (c/docker-tag)
:actual tag
:json json})))))))
(defn- validate-elastic-beanstalk-artifacts []
(u/step "Validate Elastic Beanstalk artifacts"
(common.http/check-url-exists (c/artifact-download-url "launch-aws-eb.html"))
(common.http/check-url-exists (c/artifact-download-url "metabase-aws-eb.zip"))))
(common.http/check-url-exists (c/artifact-download-url "metabase-aws-eb.zip"))
(validate-json-docker-tag)
(u/announce "Artifacts validated.")))
(defn- dockerrun-json-content []
{:AWSEBDockerrunVersion "1"
:Image {:Name (c/docker-tag)
:Update "true"}
:Ports [{:ContainerPort "3000"}]
:Logging "/var/log/metabase"})
(defn- create-archive! []
(u/step (format "Create metabase-aws-eb.zip for Docker image %s" (c/docker-tag))
(u/step "Create temp dir"
(u/delete-file-if-exists! archive-temp-dir)
(u/create-directory-unless-exists! archive-temp-dir))
(u/step "Generate Dockerrun.aws.json"
(spit (u/filename archive-temp-dir "Dockerrun.aws.json")
(json/generate-string (dockerrun-json-content) {:pretty true})))
(u/step "Copy .ebextensions"
(u/copy-file! eb-extensions-source (u/filename archive-temp-dir ".ebextensions")))
(u/step "Create metabase-aws-eb.zip"
(u/delete-file-if-exists! archive-path)
(u/sh {:dir archive-temp-dir} "zip" "--recurse-paths" archive-path ".")
(u/assert-file-exists archive-path))))
(defn- create-html-file! []
(u/step (format "Create launch-aws-eb.html for Docker image %s" (c/docker-tag))
(u/delete-file-if-exists! html-file-path)
(spit html-file-path
(stencil/render-file (u/assert-file-exists "release/elastic_beanstalk/launch-aws-eb.html.template")
{:url (java.net.URLEncoder/encode (c/artifact-download-url "metabase-aws-eb.zip")
"UTF-8")}))
(u/assert-file-exists html-file-path)))
(defn- upload-artifacts! []
(u/step "Upload Elastic Beanstalk artifacts"
(u/step "Upload metabase-aws-eb.zip"
(upload/upload-artifact! archive-path "metabase-aws-eb.zip"))
(u/step "Upload launch-aws-eb.html"
(upload/upload-artifact! html-file-path "launch-aws-eb.html"))))
;; TODO -- we should merge the EB build logic into this script, it's still an ancient bash script
(defn publish-elastic-beanstalk-artifacts! []
(u/step "Create and publish Elastic Beanstalk artifacts"
(u/sh {:dir c/root-directory} "./bin/aws-eb-docker/release-eb-version.sh" (str "v" (c/version))))
(create-archive!)
(create-html-file!)
(upload-artifacts!))
(validate-elastic-beanstalk-artifacts))
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