Commit 27e091f3 authored by Aral Balkan's avatar Aral Balkan

Refactored to use the new generated data server and completed rename to Better.

parent f40b1de6
......@@ -20,8 +20,6 @@
#
################################################################################
# TODO: Refactor: Rename all references to "Better".
#
# Helpers
#
......@@ -44,22 +42,31 @@ runIn(){
}
#
# Sets up a working copy of the specified repository.
# Sets up a working copy of a generated data repository.
#
setupRepository(){
setupGeneratedDataRepositoryWorkingCopy(){
# Store argument
nameOfRepository=$1
runIn $ROOT "git clone ${gitRepositoryPrefix}/${nameOfRepository}.git"
# Clone the working copy
# (gitRepositoryPrefixForGeneratedDataRepositories was configured by the person at script start-up)
runIn "${ROOT}/data" "git clone ${gitRepositoryPrefixForGeneratedDataRepositories}/${nameOfRepository}.git"
}
# TODO: Once we have the data.better.fyi repositories set up and
# ===== being used by the builder script, we can disable the
# origin push endpoints so as to avoid an accidental push to
# the source repositories from the deployment environment.
#
# (Not doing this until then as the builder script currently pushes
# to the data-for-apps repository.)
#
#runIn $ROOT/$nameOfRepository "git remote set-url --push origin no_push"
#
# Sets up a working copy of a source repository.
#
setupSourceRepositoryWorkingCopy(){
# Store argument
nameOfRepository=$1
# Clone the working copy
# (gitRepositoryPrefixForSourceRepositories was configured by the person at script start-up)
runIn $ROOT "git clone ${gitRepositoryPrefixForSourceRepositories}/${nameOfRepository}.git"
# Disable the origin push endpoint to avoid an accidental push to
# the source repositories from the deployment environment.
runIn $ROOT/$nameOfRepository "git remote set-url --push origin no_push"
}
# Abort on errors.
......@@ -111,14 +118,17 @@ echo -e "1. Configuration options (all defaults are for better.fyi).\n"
read -e -p " Builder domain (builder.better.fyi): " builderDomain
builderDomain=${builderDomain:-builder.better.fyi}
read -e -p " Email address for Let’s Encrypt TLS certificates (hello+builder@ind.ie): " letsEncryptEmailAddress
letsEncryptEmailAddress=${letsEncryptEmailAddress:-hello+builder@ind.ie}
read -e -p " Email address for Let’s Encrypt TLS certificates (hello+better+builder@ind.ie): " letsEncryptEmailAddress
letsEncryptEmailAddress=${letsEncryptEmailAddress:-hello+better+builder@ind.ie}
read -e -p " Git repository prefix (git@source.ind.ie:blockdown): " gitRepositoryPrefix
gitRepositoryPrefix=${gitRepositoryPrefix:-git@source.ind.ie:blockdown}
read -e -p " Git repository prefix for source repositories (git@source.ind.ie:better): " gitRepositoryPrefixForSourceRepositories
gitRepositoryPrefixForSourceRepositories=${gitRepositoryPrefixForSourceRepositories:-git@source.ind.ie:better}
read -e -p " Data for site remote repository URL (git@blockdown-site.ind.ie:data.git): " dataForSiteRemoteRepositoryURL
dataForSiteRemoteRepositoryURL=${dataForSiteRemoteRepositoryURL:-git@blockdown-site.ind.ie:data.git}
read -e -p " Git repository prefix for generated data repositories (git@data.better.fyi:generated): " gitRepositoryPrefixForGeneratedDataRepositories
gitRepositoryPrefixForGeneratedDataRepositories=${gitRepositoryPrefixForGeneratedDataRepositories:-git@data.better.fyi:generated}
read -e -p " Data for site remote repository URL (git@www.better.fyi:data.git): " dataForSiteRemoteRepositoryURL
dataForSiteRemoteRepositoryURL=${dataForSiteRemoteRepositoryURL:-git@www.better.fyi:data.git}
read -e -p " Public key (default is better.fyi’s): " publicKey
publicKey=${publicKey:-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCoeMcQpU1XaSkv9AZtvUOg0bYEoRXTQ4MREGXoAZCR0pFWfzbzG0+av6WyNulu+MU5JF87u3YnwAAB6FB92mMbRS1xMtuV0Bu5TwPj5MjUqbznm8Sd+XO7A37g0oBPWrCKe24G+dGAmRVHZjT9qisTQhKpbEW1TxdvbNxDYALTzBuUFmhCJnMYorTpOVXL0SkUX89AkoVXdjVCq55sf3MGG+AN9OomSvveZ8tK0FwGOlT9w5niNktBfVicNpQFpURSbKFCqjZp7qkDLDRebKI1grgDUELhQWYj32vNkMX3lzqC/AIqwVkEO11Y9DSalray4f7O9X9YR3hB1MPRcBSw6DD36lCtVA6cASGdzvxDMX1f7gFoq22gfGJMVVYn+uHClrlrTiXl+ueZr3+DgC2Zc+/pWhqBsJ7NdxeWRYQWVmrOAPWLthxoPKxnlgbuRR9xBugWB+F73ipNZ5/iS6/eYoqmvaC07Uta6vXoYxncSxZR2GBrE1sI0eQKtbWZKP0w6Rb44QglX+atwxNLo5CcTHqJw5OkOJf1imeh4vfQSnENkjAK72iM/mgGzBY/AfIBxUswY+L9hEFxhfbH72WVO75G1k3mqB52wdj4Sjjz8kGDpppz9LNGIBeuSmrgJl0e05F4Vw9hz2vhg4i2pFwSlGZFx/J1WfI3ZH5YicIPJQ== hello+blockdown_builder@ind.ie}
......@@ -151,7 +161,7 @@ echo -e "Configuring the Builder deployment environment…\n"
#
# Set the installation root folder.
#
readonly ROOT=~/ind.ie.blockdown-builder
readonly ROOT=~/better.fyi
#
# Reset the local environment if necessary.
......@@ -227,18 +237,31 @@ sed -i "s/{builderDomain}/${builderDomain}/g" ~/.ssh/config
#
# Set up the repositories used by the builder.
# Set up working copies of content and theme source repositories.
#
setupSourceRepositoryWorkingCopy "content"
setupSourceRepositoryWorkingCopy "themes"
#
# Set up working copies of the generated data repositories for the Better web site and the iOS app.
#
setupRepository "content"
setupRepository "themes"
setupRepository "data-for-apps"
setupRepository "data-for-site"
# Create the data folder for the generated data working copies
mkdir -p $ROOT/data
setupGeneratedDataRepositoryWorkingCopy "app"
setupGeneratedDataRepositoryWorkingCopy "site"
# Set up the site remote for the data-for-site repository
runIn $ROOT/data-for-site "git remote add site ${dataForSiteRemoteRepositoryURL}"
runIn $ROOT/data/site "git remote add site ${dataForSiteRemoteRepositoryURL}"
echo -e "Builder deployment environment configured.\n"
#
# Install and configure Dokku
#
echo -e "Installing Dokku…\n"
# Set up dokku for unattended installation using debconf
......@@ -259,18 +282,22 @@ echo -e "Setting up the Builder on Dokku and deploying…\n"
dokku apps:create $builderDomain
# Create the volumes
dokku docker-options:add $builderDomain deploy "-v $ROOT:/app/ind.ie.blockdown-builder"
dokku docker-options:add $builderDomain run "-v $ROOT:/app/ind.ie.blockdown-builder"
dokku docker-options:add $builderDomain deploy "-v $ROOT:/app/better.fyi/builder"
dokku docker-options:add $builderDomain run "-v $ROOT:/app/better.fyi/builder"
# Add the local dokku domain to known hosts so the script doesn’t prompt the person
ssh-keyscan -H $builderDomain >> ~/.ssh/known_hosts
# Check out the app source and deploy
rm -rf /tmp/builder
runIn /tmp "git clone ${gitRepositoryPrefix}/builder.git"
runIn /tmp "git clone ${gitRepositoryPrefixForSourceRepositories}/builder.git"
runIn /tmp/builder "git remote add live dokku@${builderDomain}:${builderDomain}"
runIn /tmp/builder "git push live master"
#
# Set up TLS via Let’s Encrypt.
#
# Install the Dokku Let’s Encrypt plugin for SSL
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment