mirror of
https://github.com/simonmichael/hledger.git
synced 2024-10-06 10:57:30 +03:00
Update Sandstorm build files
This commit is contained in:
parent
16fe1bcb08
commit
7996a267f7
26
.sandstorm/Vagrantfile
vendored
26
.sandstorm/Vagrantfile
vendored
@ -9,8 +9,17 @@ VM_NAME = File.basename(File.dirname(File.dirname(__FILE__))) + "_sandstorm_#{Ti
|
||||
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
# ugly hack to prevent hashicorp's bitrot. See https://github.com/hashicorp/vagrant/issues/9442
|
||||
# this setting is required for pre-2.0 vagrant, but causes an error as of 2.0.3,
|
||||
# remove entirely when confident nobody uses vagrant 1.x for anything.
|
||||
unless Vagrant::DEFAULT_SERVER_URL.frozen?
|
||||
Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com')
|
||||
end
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "sandstorm/debian-jessie64"
|
||||
# Base on the Sandstorm snapshots of the official Debian 9 (stretch) box with vboxsf support.
|
||||
config.vm.box = "debian/contrib-stretch64"
|
||||
config.vm.box_version = "9.3.0"
|
||||
|
||||
if Vagrant.has_plugin?("vagrant-vbguest") then
|
||||
# vagrant-vbguest is a Vagrant plugin that upgrades
|
||||
@ -24,7 +33,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
# We forward port 6080, the Sandstorm web port, so that developers can
|
||||
# visit their sandstorm app from their browser as local.sandstorm.io:6080
|
||||
# (aka 127.0.0.1:6080).
|
||||
config.vm.network :forwarded_port, guest: 6080, host: 6080
|
||||
config.vm.network :forwarded_port, guest: 6080, host: 6080, host_ip: "127.0.0.1"
|
||||
|
||||
# Use a shell script to "provision" the box. This installs Sandstorm using
|
||||
# the bundled installer.
|
||||
@ -71,25 +80,32 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
if total_kB_ram.nil? or total_kB_ram < 2048000
|
||||
assign_ram_mb = 512
|
||||
else
|
||||
assign_ram_mb = (total_kB_ram / 1024 / 2)
|
||||
assign_ram_mb = (total_kB_ram / 1024 / 4)
|
||||
end
|
||||
# Actually apply these CPU/memory values to the providers.
|
||||
config.vm.provider :virtualbox do |vb, override|
|
||||
vb.cpus = cpus
|
||||
vb.memory = assign_ram_mb
|
||||
vb.name = VM_NAME
|
||||
vb.customize ["modifyvm", :id, "--nictype1", "Am79C973"]
|
||||
|
||||
# /opt/app and /host-dot-sandstorm are used by vagrant-spk
|
||||
override.vm.synced_folder "..", "/opt/app"
|
||||
override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm"
|
||||
override.vm.synced_folder "..", "/vagrant"
|
||||
# /vagrant is not used by vagrant-spk; we need this line so it gets disabled; if we removed the
|
||||
# line, vagrant would automatically insert a synced folder in /vagrant, which is not what we want.
|
||||
override.vm.synced_folder "..", "/vagrant", disabled: true
|
||||
end
|
||||
config.vm.provider :libvirt do |libvirt, override|
|
||||
libvirt.cpus = cpus
|
||||
libvirt.memory = assign_ram_mb
|
||||
libvirt.default_prefix = VM_NAME
|
||||
|
||||
# /opt/app and /host-dot-sandstorm are used by vagrant-spk
|
||||
override.vm.synced_folder "..", "/opt/app", type: "9p", accessmode: "passthrough"
|
||||
override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm", type: "9p", accessmode: "passthrough"
|
||||
override.vm.synced_folder "..", "/vagrant", type: "9p", accessmode: "passthrough"
|
||||
# /vagrant is not used by vagrant-spk; we need this line so it gets disabled; if we removed the
|
||||
# line, vagrant would automatically insert a synced folder in /vagrant, which is not what we want.
|
||||
override.vm.synced_folder "..", "/vagrant", type: "9p", accessmode: "passthrough", disabled: true
|
||||
end
|
||||
end
|
||||
|
2
.sandstorm/build.sh
Normal file → Executable file
2
.sandstorm/build.sh
Normal file → Executable file
@ -19,7 +19,7 @@ set -euo pipefail
|
||||
|
||||
# By default, this script does nothing. You'll have to modify it as
|
||||
# appropriate for your application.
|
||||
cd /opt/app/hledger
|
||||
cd /opt/app
|
||||
stack setup
|
||||
stack install hledger-web
|
||||
sudo cp /home/vagrant/.local/bin/hledger-web /usr/local/bin
|
||||
|
@ -1,14 +1,35 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Set options for curl. Since we only want to show errors from these curl commands, we also use
|
||||
# 'cat' to buffer the output; for more information:
|
||||
# https://github.com/sandstorm-io/vagrant-spk/issues/158
|
||||
|
||||
CURL_OPTS="--silent --show-error"
|
||||
echo localhost > /etc/hostname
|
||||
hostname localhost
|
||||
curl https://install.sandstorm.io/ > /host-dot-sandstorm/caches/install.sh
|
||||
SANDSTORM_CURRENT_VERSION=$(curl -fs "https://install.sandstorm.io/dev?from=0&type=install")
|
||||
|
||||
# Install curl that is needed below.
|
||||
apt-get update
|
||||
apt-get install -y curl
|
||||
|
||||
# The following line copies stderr through stderr to cat without accidentally leaving it in the
|
||||
# output file. Be careful when changing. See: https://github.com/sandstorm-io/vagrant-spk/pull/159
|
||||
curl $CURL_OPTS https://install.sandstorm.io/ 2>&1 > /host-dot-sandstorm/caches/install.sh | cat
|
||||
|
||||
SANDSTORM_CURRENT_VERSION=$(curl $CURL_OPTS -f "https://install.sandstorm.io/dev?from=0&type=install")
|
||||
SANDSTORM_PACKAGE="sandstorm-$SANDSTORM_CURRENT_VERSION.tar.xz"
|
||||
if [[ ! -f /host-dot-sandstorm/caches/$SANDSTORM_PACKAGE ]] ; then
|
||||
curl --output "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE" "https://dl.sandstorm.io/$SANDSTORM_PACKAGE"
|
||||
echo -n "Downloading Sandstorm version ${SANDSTORM_CURRENT_VERSION}..."
|
||||
curl $CURL_OPTS --output "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "https://dl.sandstorm.io/$SANDSTORM_PACKAGE" 2>&1 | cat
|
||||
mv "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE"
|
||||
echo "...done."
|
||||
fi
|
||||
if [ ! -e /opt/sandstorm/latest/sandstorm ] ; then
|
||||
echo -n "Installing Sandstorm version ${SANDSTORM_CURRENT_VERSION}..."
|
||||
bash /host-dot-sandstorm/caches/install.sh -d -e "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE" >/dev/null
|
||||
echo "...done."
|
||||
fi
|
||||
bash /host-dot-sandstorm/caches/install.sh -d -e "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE"
|
||||
modprobe ip_tables
|
||||
# Make the vagrant user part of the sandstorm group so that commands like
|
||||
# `spk dev` work.
|
||||
@ -17,14 +38,11 @@ usermod -a -G 'sandstorm' 'vagrant'
|
||||
sudo sed --in-place='' \
|
||||
--expression='s/^BIND_IP=.*/BIND_IP=0.0.0.0/' \
|
||||
/opt/sandstorm/sandstorm.conf
|
||||
# TODO: update sandstorm installer script to ask about dev accounts, and
|
||||
# specify a value for this option in the default config?
|
||||
if ! grep --quiet --no-messages ALLOW_DEV_ACCOUNTS=true /opt/sandstorm/sandstorm.conf ; then
|
||||
echo "ALLOW_DEV_ACCOUNTS=true" | sudo tee -a /opt/sandstorm/sandstorm.conf
|
||||
sudo service sandstorm restart
|
||||
fi
|
||||
sudo service sandstorm restart
|
||||
# Enable apt-cacher-ng proxy to make things faster if one appears to be running on the gateway IP
|
||||
GATEWAY_IP=$(ip route | grep ^default | cut -d ' ' -f 3)
|
||||
if nc -z "$GATEWAY_IP" 3142 ; then
|
||||
echo "Acquire::http::Proxy \"http://$GATEWAY_IP:3142\";" > /etc/apt/apt.conf.d/80httpproxy
|
||||
fi
|
||||
# Configure apt to retry fetching things that fail to download.
|
||||
echo "APT::Acquire::Retries \"10\";" > /etc/apt/apt.conf.d/80sandstorm-retry
|
||||
|
Loading…
Reference in New Issue
Block a user