From 9d15fb314f67a1a61464738c623d1b1ba6bcce39 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 18 Dec 2016 12:11:06 -0800 Subject: [PATCH] add needed files for deployment --- Dockerfile | 1 + backend/christine.website/main.go | 7 ++++- box.rb | 46 +++++++++++++++++++++++++++++++ build.sh | 19 +++++++++++++ frontend/bower.json | 3 ++ run.sh | 4 +++ runit/backplane/run | 8 ++++++ 7 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 box.rb create mode 100755 build.sh create mode 100755 run.sh create mode 100755 runit/backplane/run diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1890408 --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +FROM xena/christine.website diff --git a/backend/christine.website/main.go b/backend/christine.website/main.go index e271802..1e28382 100644 --- a/backend/christine.website/main.go +++ b/backend/christine.website/main.go @@ -130,7 +130,12 @@ func main() { http.Handle("/static/", http.FileServer(http.Dir("."))) http.HandleFunc("/", writeIndexHTML) - log.Fatal(http.ListenAndServe(":9090", nil)) + port := os.Getenv("PORT") + if port == "" { + port = "9090" + } + + log.Fatal(http.ListenAndServe(":"+port, nil)) } func writeBlogPosts(w http.ResponseWriter, r *http.Request) { diff --git a/box.rb b/box.rb new file mode 100644 index 0000000..2ebf5cb --- /dev/null +++ b/box.rb @@ -0,0 +1,46 @@ +from "phusion/baseimage:0.9.19" + +copy "./runit/", "/etc/system/" + +run %q[ curl -o backplane-stable-linux-amd64.tgz https://bin.equinox.io/c/jWahGASjoRq/backplane-stable-linux-amd64.tgz \ + && tar xf backplane-stable-linux-amd64.tgz \ + && mv backplane /usr/bin/backplane \ + && rm backplane-stable-linux-amd64.tgz ] + +run %q[ cd /usr/local && curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz \ + && tar xf go.tar.gz && rm go.tar.gz && mkdir -p /go/src ] +env "GOPATH" => "/go" +run %q[ apt-get update && apt-get install -y git-core \ + && /usr/local/go/bin/go get github.com/gernest/front && /usr/local/go/bin/go get gopkg.in/yaml.v2 ] + +run %q[ apt-get update && apt-get install xz-utils bzip2 ] + +run %q[ cd /usr/local && curl -o node.tar.xz https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz \ + && tar xf node.tar.xz && mv node-v6.9.2-linux-x64 node && rm node.tar.xz ] + +### Copy files +run "mkdir -p /site" +copy "./backend", "/site/backend" +copy "./blog", "/site/blog" +copy "./frontend/package.json", "/site/frontend/package.json" +copy "./frontend/bower.json", "/site/frontend/bower.json" +copy "./frontend/webpack.production.config.js", "/site/frontend/webpack.production.config.js" +copy "./frontend/src", "/site/frontend/src" +copy "./frontend/support", "/site/frontend/support" +copy "./static", "/site/static" +copy "./build.sh", "/site/build.sh" +copy "./run.sh", "/site/run.sh" + +### Build +run %q[ cd /site && bash ./build.sh ] + +### Cleanup +run %q[ rm -rf /usr/local/go /usr/local/node /site/frontend/node_modules /site/frontend/bower_components /go /site/backend ] +run %q[ apt-get remove -y xz-utils bzip2 git-core ] + +### Runtime +entrypoint "/sbin/my_init" +cmd "/site/run.sh" + +flatten +tag "xena/christine.website" diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..9813f7f --- /dev/null +++ b/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -x + +export PATH="$PATH:/usr/local/go/bin:/usr/local/node/bin" +export CI="true" + +(cd /site/frontend + yes | npm install + npm install -g bower + yes 2 | bower install --allow-root + npm run build + rm -rf bower_components node_modules) & + +(cd /site/backend/christine.website + go build + mv christine.website /usr/bin) & + +wait diff --git a/frontend/bower.json b/frontend/bower.json index 2293bee..1ba4949 100644 --- a/frontend/bower.json +++ b/frontend/bower.json @@ -12,5 +12,8 @@ "purescript-pux-devtool": "^4.1.0", "purescript-argonaut": "^2.0.0", "purescript-affjax": "^3.0.2" + }, + "resolutions": { + "purescript-dom": "^3.1.0" } } diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..a89bb2a --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd /site +/usr/bin/christine.website diff --git a/runit/backplane/run b/runit/backplane/run new file mode 100755 index 0000000..0394912 --- /dev/null +++ b/runit/backplane/run @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -n "$BACKPLANE_TOKEN" ] +then + /usr/bin/backplane connect +else + sleep 999d +fi