Permalink
Browse files

Work on migrating to kubernetes

  • Loading branch information...
mwylde committed Mar 20, 2017
1 parent e3f54e4 commit 1b028eb38dfb7b5f1a617ae5dcebe15ebf11dccb
Showing with 160 additions and 7 deletions.
  1. +32 −0 Dockerfile
  2. +5 −0 Gemfile
  3. +17 −0 Gemfile.lock
  4. +23 −0 cronjob.yaml
  5. +5 −1 get_data.rb
  6. +13 −0 hnhiring.tf
  7. +2 −2 pub/index.html
  8. +5 −3 pub/scripts.js
  9. +1 −1 pub/styles.css
  10. +39 −0 terraform.tfstate
  11. +16 −0 terraform.tfstate.backup
  12. +2 −0 upload_data.sh
View
@@ -0,0 +1,32 @@
FROM ruby:2.4-alpine
RUN apk update && apk add ca-certificates wget && update-ca-certificates
RUN apk add --virtual build-dependencies ruby-dev build-base
RUN apk add python
ENV HOME /
ENV CLOUDSDK_PYTHON_SITEPACKAGES 1
RUN wget https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip && unzip google-cloud-sdk.zip && rm google-cloud-sdk.zip
RUN google-cloud-sdk/install.sh --usage-reporting=true --path-update=true --bash-completion=true --rc-path=/.bashrc
RUN google-cloud-sdk/bin/gcloud config set --installation component_manager/disable_update_check true
RUN sed -i -- 's/\"disable_updater\": false/\"disable_updater\": true/g' /google-cloud-sdk/lib/googlecloudsdk/core/config.json
RUN mkdir /.ssh
ENV PATH /google-cloud-sdk/bin:$PATH
VOLUME ["/.config"]
RUN mkdir /usr/app
RUN mkdir /usr/data
WORKDIR /usr/app
ADD Gemfile .
ADD Gemfile.lock .
ADD get_data.rb .
ADD upload_data.sh .
RUN gem install bundler --no-ri --no-rdoc && \
cd /usr/app ; bundle install --without development test && \
apk del build-dependencies
CMD ["/bin/sh", "-c", "/usr/app/get_data.rb /usr/data && ./upload_data.sh /usr/data"]
View
@@ -0,0 +1,5 @@
# A sample Gemfile
source "https://rubygems.org"
gem "nokogiri"
gem 'redis'
View
@@ -0,0 +1,17 @@
GEM
remote: https://rubygems.org/
specs:
mini_portile2 (2.1.0)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
redis (3.3.3)
PLATFORMS
ruby
DEPENDENCIES
nokogiri
redis
BUNDLED WITH
1.11.2
View
@@ -0,0 +1,23 @@
apiVersion: batch/v2alpha1
kind: CronJob
metadata:
name: hnhiring-get-data
spec:
# schedule: "0,15,30,45 13,14,15,16,17,18,19,20,21,22,23 * * *"
schedule: "*/5 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hnhiring-get-data
image: "gcr.io/micahw-com/github-mwylde-hnhiring:cb33257c04ea230d7cf33390a8e858c8928ec297"
env:
- name: REDIS_HOST
value: "pub-redis-18045.us-central1-1-1.gce.garantiadata.com"
- name: REDIS_PORT
value: "18045"
- name: REDIS_PASS
value: "wCol4+Dz2TmIUcJQ"
restartPolicy: Never
# concurrencyPolicy: Forbid
View
6 get_data.rb 100644 → 100755
@@ -1,3 +1,5 @@
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
require 'json'
@@ -25,7 +27,9 @@
# HN doesn't like bots, even responsible ones
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17"
@redis = Redis.new
@redis = Redis.new(host: ENV['REDIS_HOST'],
port: ENV['REDIS_PORT'],
password: ENV['REDIS_PASS'])
def handle_time id, s
if t = @redis.get("hnhiring:comments:#{id}")
View
@@ -0,0 +1,13 @@
provider "google" {
project = "micahw-com"
region = "us-central1-a"
}
resource "google_storage_bucket" "www-hnhiring-me" {
name = "www.hnhiring.me"
storage_class = "MULTI_REGIONAL"
website {
main_page_suffix = "index.html"
}
}
View
@@ -2,8 +2,8 @@
<html>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<script type="text/javascript" src="/scripts.js?389058268"></script>
<link rel="stylesheet" href="/styles.css?125765381" />
<script type="text/javascript" src="/scripts.js?59677095"></script>
<link rel="stylesheet" href="/styles.css?883591472" />
<title>HN Hiring</title>
<script type='text/javascript'>
//<![CDATA[
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,39 @@
{
"version": 3,
"terraform_version": "0.9.1",
"serial": 1,
"lineage": "8a7a575a-e8c8-49b0-8645-5422a6780ed5",
"modules": [
{
"path": [
"root"
],
"outputs": {},
"resources": {
"google_storage_bucket.www-hnhiring-me": {
"type": "google_storage_bucket",
"depends_on": [],
"primary": {
"id": "www.hnhiring.me",
"attributes": {
"force_destroy": "false",
"id": "www.hnhiring.me",
"location": "US",
"name": "www.hnhiring.me",
"self_link": "https://www.googleapis.com/storage/v1/b/www.hnhiring.me",
"storage_class": "MULTI_REGIONAL",
"website.#": "1",
"website.0.main_page_suffix": "index.html",
"website.0.not_found_page": ""
},
"meta": {},
"tainted": false
},
"deposed": [],
"provider": ""
}
},
"depends_on": []
}
]
}
View
@@ -0,0 +1,16 @@
{
"version": 3,
"terraform_version": "0.9.1",
"serial": 0,
"lineage": "8a7a575a-e8c8-49b0-8645-5422a6780ed5",
"modules": [
{
"path": [
"root"
],
"outputs": {},
"resources": {},
"depends_on": []
}
]
}
View
@@ -0,0 +1,2 @@
gsutil defacl set public-read gs://www.micahw.com
gsutil rsync -R $1 gs://www.hnhiring.me/data

0 comments on commit 1b028eb

Please sign in to comment.