Merge branch 'sethvargo/docker_website'

This commit is contained in:
Mitchell Hashimoto 2016-10-31 17:46:09 -07:00
commit 3630bb0e3f
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
10 changed files with 98 additions and 138 deletions

View File

@ -1,4 +1,3 @@
source "https://rubygems.org" source "https://rubygems.org"
gem "middleman-hashicorp", gem "middleman-hashicorp", "0.3.4"
git: "https://github.com/hashicorp/middleman-hashicorp.git"

View File

@ -1,23 +1,3 @@
GIT
remote: https://github.com/hashicorp/middleman-hashicorp.git
revision: 80ddc227b26cbbb3742d14396f26172174222080
specs:
middleman-hashicorp (0.2.0)
bootstrap-sass (~> 3.3)
builder (~> 3.2)
less (~> 2.6)
middleman (~> 3.4)
middleman-livereload (~> 3.4)
middleman-minify-html (~> 3.4)
middleman-syntax (~> 2.0)
rack-contrib (~> 1.2)
rack-protection (~> 1.5)
rack-rewrite (~> 1.5)
rack-ssl-enforcer (~> 0.2)
redcarpet (~> 3.2)
therubyracer (~> 0.12)
thin (~> 1.6)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
@ -27,7 +7,7 @@ GEM
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4) thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
autoprefixer-rails (6.4.1.1) autoprefixer-rails (6.5.1.1)
execjs execjs
bootstrap-sass (3.3.7) bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1) autoprefixer-rails (>= 5.2.1)
@ -44,7 +24,6 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.10.0) coffee-script-source (1.10.0)
commonjs (0.2.7)
compass (1.0.3) compass (1.0.3)
chunky_png (~> 1.2) chunky_png (~> 1.2)
compass-core (~> 1.0.2) compass-core (~> 1.0.2)
@ -57,7 +36,6 @@ GEM
sass (>= 3.3.0, < 3.5) sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5) compass-import-once (1.0.5)
sass (>= 3.2, < 3.5) sass (>= 3.2, < 3.5)
daemons (1.2.4)
em-websocket (0.5.1) em-websocket (0.5.1)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
@ -65,20 +43,15 @@ GEM
eventmachine (1.2.0.1) eventmachine (1.2.0.1)
execjs (2.7.0) execjs (2.7.0)
ffi (1.9.14) ffi (1.9.14)
git-version-bump (0.15.1)
haml (4.0.7) haml (4.0.7)
tilt tilt
hike (1.2.3) hike (1.2.3)
hooks (0.4.1) hooks (0.4.1)
uber (~> 0.0.14) uber (~> 0.0.14)
htmlcompressor (0.2.0)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
i18n (0.7.0) i18n (0.7.0)
json (1.8.3) json (1.8.3)
kramdown (1.12.0) kramdown (1.12.0)
less (2.6.0)
commonjs (~> 0.2.7)
libv8 (3.16.14.15)
listen (3.0.8) listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
@ -105,55 +78,49 @@ GEM
rack (>= 1.4.5, < 2.0) rack (>= 1.4.5, < 2.0)
thor (>= 0.15.2, < 2.0) thor (>= 0.15.2, < 2.0)
tilt (~> 1.4.1, < 2.0) tilt (~> 1.4.1, < 2.0)
middleman-hashicorp (0.3.4)
bootstrap-sass (~> 3.3)
builder (~> 3.2)
middleman (~> 3.4)
middleman-livereload (~> 3.4)
middleman-syntax (~> 3.0)
redcarpet (~> 3.3)
middleman-livereload (3.4.6) middleman-livereload (3.4.6)
em-websocket (~> 0.5.1) em-websocket (~> 0.5.1)
middleman-core (>= 3.3) middleman-core (>= 3.3)
rack-livereload (~> 0.3.15) rack-livereload (~> 0.3.15)
middleman-minify-html (3.4.1)
htmlcompressor (~> 0.2.0)
middleman-core (>= 3.2)
middleman-sprockets (3.5.0) middleman-sprockets (3.5.0)
middleman-core (>= 3.3) middleman-core (>= 3.3)
sprockets (~> 2.12.1) sprockets (~> 2.12.1)
sprockets-helpers (~> 1.1.0) sprockets-helpers (~> 1.1.0)
sprockets-sass (~> 1.3.0) sprockets-sass (~> 1.3.0)
middleman-syntax (2.1.0) middleman-syntax (3.0.0)
middleman-core (>= 3.2) middleman-core (>= 3.2)
rouge (~> 1.0) rouge (~> 2.0)
mime-types (3.1) mime-types (3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521) mime-types-data (3.2016.0521)
mini_portile2 (2.1.0) mini_portile2 (2.1.0)
minitest (5.9.1) minitest (5.9.1)
multi_json (1.12.1) multi_json (1.12.1)
nokogiri (1.6.8) nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
padrino-helpers (0.12.8.1) padrino-helpers (0.12.8.1)
i18n (~> 0.6, >= 0.6.7) i18n (~> 0.6, >= 0.6.7)
padrino-support (= 0.12.8.1) padrino-support (= 0.12.8.1)
tilt (~> 1.4.1) tilt (~> 1.4.1)
padrino-support (0.12.8.1) padrino-support (0.12.8.1)
activesupport (>= 3.1) activesupport (>= 3.1)
pkg-config (1.1.7)
rack (1.6.4) rack (1.6.4)
rack-contrib (1.4.0)
git-version-bump (~> 0.15)
rack (~> 1.4)
rack-livereload (0.3.16) rack-livereload (0.3.16)
rack rack
rack-protection (1.5.3)
rack
rack-rewrite (1.5.1)
rack-ssl-enforcer (0.2.9)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rb-fsevent (0.9.7) rb-fsevent (0.9.8)
rb-inotify (0.9.7) rb-inotify (0.9.7)
ffi (>= 0.5.0) ffi (>= 0.5.0)
redcarpet (3.3.4) redcarpet (3.3.4)
ref (2.0.0) rouge (2.0.6)
rouge (1.11.1)
sass (3.4.22) sass (3.4.22)
sprockets (2.12.4) sprockets (2.12.4)
hike (~> 1.2) hike (~> 1.2)
@ -165,13 +132,6 @@ GEM
sprockets-sass (1.3.1) sprockets-sass (1.3.1)
sprockets (~> 2.0) sprockets (~> 2.0)
tilt (~> 1.1) tilt (~> 1.1)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thin (1.7.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (1.4.1)
@ -188,7 +148,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
middleman-hashicorp! middleman-hashicorp (= 0.3.4)
BUNDLED WITH BUNDLED WITH
1.13.1 1.13.6

View File

@ -1,10 +1,14 @@
all: build VERSION?="0.3.4"
init: website:
bundle @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 .PHONY: website
bundle exec middleman server
build: init
bundle exec middleman build

View File

@ -1,10 +1,10 @@
# Terraform Website # Terraform Website
This subdirectory contains the entire source for the [Terraform Website](http://www.terraform.io). This subdirectory contains the entire source for the [Terraform Website](https://www.terraform.io/).
This is a [Middleman](http://middlemanapp.com) project, which builds a static This is a [Middleman](http://middlemanapp.com) project, which builds a static
site from these source files. site from these source files.
## Contributions Welcome ## Contributions Welcome!
If you find a typo or you feel like you can improve the HTML, CSS, or If you find a typo or you feel like you can improve the HTML, CSS, or
JavaScript, we welcome contributions. Feel free to open issues or pull JavaScript, we welcome contributions. Feel free to open issues or pull
@ -12,7 +12,19 @@ requests like any normal GitHub project, and we'll merge it in.
## Running the Site Locally ## Running the Site Locally
Running the site locally is simple. First you need a working copy of [Ruby >= 2.0](https://www.ruby-lang.org/en/downloads/) and [Bundler](http://bundler.io/). Then you can 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 ```shell
".html" to make them work (in the navigation). $ 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`.

36
website/Vagrantfile vendored
View File

@ -1,36 +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
# manually install GPG key in a proxy-friendly way
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable
. ~/.bashrc
. ~/.bash_profile
rvm install 2.0.0
rvm --default use 2.0.0
# Middleman deps
cd /vagrant
gem install bundle
sudo apt-get install -y git-core
bundle
# Run the middleman server
bundle exec middleman server &
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.provision "shell", inline: $script, privileged: false
config.vm.synced_folder ".", "/vagrant", type: "rsync"
config.vm.network "forwarded_port", guest: 4567, host: 4567
end

View File

@ -5,3 +5,38 @@ activate :hashicorp do |h|
h.version = "0.7.7" h.version = "0.7.7"
h.github_slug = "hashicorp/terraform" h.github_slug = "hashicorp/terraform"
end end
helpers do
# Get the title for the page.
#
# @param [Middleman::Page] page
#
# @return [String]
def title_for(page)
if page && page.data.page_title
return "#{page.data.page_title} - Terraform by HashiCorp"
end
"Terraform by HashiCorp"
end
# Get the description for the page
#
# @param [Middleman::Page] page
#
# @return [String]
def description_for(page)
return escape_html(page.data.description || "")
end
# This helps by setting the "active" class for sidebar nav elements
# if the YAML frontmatter matches the expected value.
def sidebar_current(expected)
current = current_page.data.sidebar_current || ""
if current == expected or (expected.is_a?(Regexp) and expected.match(current))
return " class=\"active\""
else
return ""
end
end
end

View File

@ -1,12 +0,0 @@
module SidebarHelpers
# This helps by setting the "active" class for sidebar nav elements
# if the YAML frontmatter matches the expected value.
def sidebar_current(expected)
current = current_page.data.sidebar_current || ""
if current == expected or (expected.is_a?(Regexp) and expected.match(current))
return " class=\"active\""
else
return ""
end
end
end

View File

@ -8,15 +8,16 @@
"builders": [ "builders": [
{ {
"type": "docker", "type": "docker",
"image": "ruby:2.3-slim", "image": "hashicorp/middleman-hashicorp:0.3.4",
"commit": "true" "discard": "true",
"run_command": ["-d", "-i", "-t", "{{ .Image }}", "/bin/sh"]
} }
], ],
"provisioners": [ "provisioners": [
{ {
"type": "file", "type": "file",
"source": ".", "source": ".",
"destination": "/app" "destination": "/website"
}, },
{ {
"type": "shell", "type": "shell",
@ -27,16 +28,9 @@
"FASTLY_API_KEY={{ user `fastly_api_key` }}" "FASTLY_API_KEY={{ user `fastly_api_key` }}"
], ],
"inline": [ "inline": [
"apt-get -qq update", "bundle check || bundle install",
"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 exec middleman build", "bundle exec middleman build",
"/bin/sh ./scripts/deploy.sh"
"/bin/bash ./scripts/deploy.sh"
] ]
} }
] ]

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e
PROJECT="terraform" PROJECT="terraform"
@ -28,11 +28,8 @@ if ! command -v "s3cmd" >/dev/null 2>&1; then
exit 1 exit 1
fi fi
# Get the parent directory of where this script is and change into our website # Get the parent directory of where this script is and cd there
# directory DIR="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$(cd -P "$( dirname "$SOURCE" )/.." && pwd)"
# Delete any .DS_Store files for our OS X friends. # Delete any .DS_Store files for our OS X friends.
find "$DIR" -type f -name '.DS_Store' -delete find "$DIR" -type f -name '.DS_Store' -delete
@ -106,6 +103,13 @@ fi
# Warm the cache with recursive wget. # Warm the cache with recursive wget.
if [ -z "$NO_WARM" ]; then if [ -z "$NO_WARM" ]; then
echo "Warming Fastly cache..." 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 \ wget \
--recursive \ --recursive \
--delete-after \ --delete-after \

View File

@ -3,11 +3,11 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<%= current_page.data.description %>"> <meta name="description" content="<%= description_for(current_page) %>">
<link rel="shortcut icon" href="<%= image_path('favicon.png') %>"> <link rel="shortcut icon" href="<%= image_path('favicon.png') %>">
<title><%= [current_page.data.page_title, "Terraform by HashiCorp"].compact.join(" - ") %></title> <title><%= title_for(current_page) %></title>
<%= stylesheet_link_tag "application" %> <%= stylesheet_link_tag "application" %>