Skip to content

Instantly share code, notes, and snippets.

@joadr
Last active April 12, 2017 18:46
Show Gist options
  • Save joadr/ae908fdea4dc912aa115b8be8639d056 to your computer and use it in GitHub Desktop.
Save joadr/ae908fdea4dc912aa115b8be8639d056 to your computer and use it in GitHub Desktop.
Local Meteor Build for Orion Hostin
#!/bin/bash
set -e
echo ""
echo "====> Creating app bundle..."
echo ""
TMPFOLDER=$(mktemp -d)
meteor build --architecture=os.linux.x86_64 $TMPFOLDER --server-only --allow-superuser
echo ""
echo "====> Pushing Bundle"
echo ""
echo "This could take a while..."
S3KEY="" # Your amazon IAM User key and secret
S3SECRET=""
S3PATH="/deploys/" # S3 path folder
S3BUCKET="" # S3 Bucket
AUTH_TOKEN="" # Orion Hosting Auth Token
ORION_APP="" # Your app name in Orion Hosting
putS3 () {
path=$TMPFOLDER
file="${PWD##*/}.tar.gz"
aws_path=$S3PATH
bucket=$S3BUCKET
date=$(TZ=utc date "-R")
acl="x-amz-acl:public-read"
content_type='application/x-compressed-tar'
string="PUT\n\n$content_type\n$date\n$acl\n/$bucket$aws_path$file"
signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
curl --progress-bar -X PUT -T "$path/$file" \
-H "Host: $bucket.s3.amazonaws.com" \
-H "Date: $date" \
-H "Content-Type: $content_type" \
-H "$acl" \
-H "Authorization: AWS ${S3KEY}:$signature" \
"https://$bucket.s3.amazonaws.com$aws_path$file"
}
putS3
echo ""
echo "====> Deploying to Orion Hosting"
echo ""
curl -s -X POST -H "Authorization: $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "mutation { deployApp(appName: \"'$ORION_APP'\") { name status } }"}' \
https://api.orion.hosting/graphql
echo ""
echo "====> Deleting Temp Files"
echo ""
rm -rf $TMPFOLDER
echo "Now it's deploying on Orion Hosting. Checkout https://dashboard.orion.hosting/apps/$ORION_APP/activity for progress"
echo ""
echo "====> SCRIPT FINISHED"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment