Move to container-based build process

This commit is contained in:
Seth Vargo 2016-10-21 20:34:59 -07:00
parent c1168bf95c
commit ca3d62923d
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
8 changed files with 49 additions and 82 deletions

View File

@ -63,12 +63,6 @@ vet:
echo "[LINT] Found "log"".Printf" calls. These should use Nomad's logger instead."; \
fi
web:
./scripts/website_run.sh
web-push:
./scripts/website_push.sh
# bootstrap the build by downloading additional tools
bootstrap:
@for tool in $(EXTERNAL_TOOLS) ; do \
@ -82,4 +76,4 @@ install: bin/nomad
travis:
@sh -c "'$(PWD)/scripts/travis.sh'"
.PHONY: all bin cov integ test vet web web-push test-nodep
.PHONY: all bin cov integ test vet test-nodep

View File

@ -1,3 +1,3 @@
source "https://rubygems.org"
gem "middleman-hashicorp"
gem "middleman-hashicorp", "0.3.3"

View File

@ -7,7 +7,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
autoprefixer-rails (6.5.0.2)
autoprefixer-rails (6.5.1)
execjs
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
@ -78,7 +78,7 @@ GEM
rack (>= 1.4.5, < 2.0)
thor (>= 0.15.2, < 2.0)
tilt (~> 1.4.1, < 2.0)
middleman-hashicorp (0.3.0)
middleman-hashicorp (0.3.3)
bootstrap-sass (~> 3.3)
builder (~> 3.2)
middleman (~> 3.4)
@ -148,7 +148,7 @@ PLATFORMS
ruby
DEPENDENCIES
middleman-hashicorp
middleman-hashicorp (= 0.3.3)
BUNDLED WITH
1.13.1
1.13.5

View File

@ -1,10 +1,14 @@
all: build
VERSION?="0.3.3"
init:
bundle
website:
@echo "==> Starting website in Docker..."
@docker run \
--interactive \
--rm \
--tty \
--publish "4567:4567" \
--publish "35729:35729" \
--volume "$(shell pwd):/website" \
hashicorp/middleman-hashicorp:${VERSION}
dev: init
bundle exec middleman server
build: init
bundle exec middleman build
.PHONY :website

View File

@ -12,7 +12,19 @@ requests like any normal GitHub project, and we'll merge it in.
## Running the Site Locally
Running the site locally is simple. Clone this repo and run `make dev`.
To run the site locally, clone this repository and run:
Then open up `http://localhost:4567`. Note that some URLs you may need to append
".html" to make them work (in the navigation).
```shell
$ make website
```
You must have Docker installed for this to work.
Alternatively, you can manually run the website like this:
```shell
$ bundle
$ bundle exec middleman server
```
Then open up `http://localhost:4567`.

41
website/Vagrantfile vendored
View File

@ -1,41 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
sudo apt-get -y update
# RVM/Ruby
sudo apt-get -y install curl git
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable
. ~/.bashrc
. ~/.bash_profile
rvm install 2.2.2
rvm --default use 2.2.2
gem install bundler
# Middleman deps
cd /vagrant
bundle
# JS stuff
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update -y
sudo apt-get install -y nodejs
# Get JS deps
# cd /vagrant/source
# npm install
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/ubuntu-12.04"
config.vm.network "private_network", ip: "33.33.30.10"
config.vm.network "forwarded_port", guest: 4567, host: 8080
config.vm.provision "shell", inline: $script, privileged: false
config.vm.synced_folder ".", "/vagrant"
end

View File

@ -8,15 +8,16 @@
"builders": [
{
"type": "docker",
"image": "ruby:2.3-slim",
"commit": "true"
"image": "hashicorp/middleman-hashicorp:0.3.3",
"discard": "true",
"run_command": ["-d", "-i", "-t", "{{ .Image }}", "/bin/sh"]
}
],
"provisioners": [
{
"type": "file",
"source": ".",
"destination": "/app"
"destination": "/website"
},
{
"type": "shell",
@ -27,16 +28,9 @@
"FASTLY_API_KEY={{ user `fastly_api_key` }}"
],
"inline": [
"apt-get -qq update",
"apt-get -yqq install build-essential curl git libffi-dev wget",
"apt-get -yqq install python-pip",
"pip install s3cmd",
"cd /app",
"bundle check || bundle install --jobs 7",
"bundle check || bundle install",
"bundle exec middleman build",
"/bin/bash ./scripts/deploy.sh"
"/bin/sh ./scripts/deploy.sh"
]
}
]

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e
PROJECT="nomad"
@ -28,11 +28,8 @@ if ! command -v "s3cmd" >/dev/null 2>&1; then
exit 1
fi
# Get the parent directory of where this script is and change into our website
# directory
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$(cd -P "$( dirname "$SOURCE" )/.." && pwd)"
# Get the parent directory of where this script is and cd there
DIR="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
# Delete any .DS_Store files for our OS X friends.
find "$DIR" -type f -name '.DS_Store' -delete
@ -106,6 +103,13 @@ fi
# Warm the cache with recursive wget.
if [ -z "$NO_WARM" ]; then
echo "Warming Fastly cache..."
echo ""
echo "If this step fails, there are likely missing or broken assets or links"
echo "on the website. Run the following command manually on your laptop, and"
echo "search for \"ERROR\" in the output:"
echo ""
echo "wget --recursive --delete-after https://$PROJECT_URL/"
echo ""
wget \
--recursive \
--delete-after \