Skip to content

Commit

Permalink
node6
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jun 13, 2016
1 parent 8fc76aa commit 1078a11
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM mhart/alpine-node:5.10.1
FROM mhart/alpine-node:6.2.1

# Tools
RUN apk update && apk add git curl wget bash

# Java
# RUN apk update && apk add openjdk8=8.77.03-r0
#RUN apk update && apk add openjdk8=8.92.14-r1
# Here we install GNU libc (aka glibc) and set C.UTF-8 locale as default.

RUN ALPINE_GLIBC_BASE_URL="https://github.com/andyshinn/alpine-pkg-glibc/releases/download" && \
ALPINE_GLIBC_PACKAGE_VERSION="2.23-r1" && \
RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" && \
ALPINE_GLIBC_PACKAGE_VERSION="2.23-r2" && \
ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
apk add --no-cache --virtual=build-dependencies wget ca-certificates && \
wget \
"https://raw.githubusercontent.com/andyshinn/alpine-pkg-glibc/master/andyshinn.rsa.pub" \
-O "/etc/apk/keys/andyshinn.rsa.pub" && \
"https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub" \
-O "/etc/apk/keys/sgerrand.rsa.pub" && \
wget \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
Expand All @@ -25,7 +25,7 @@ RUN ALPINE_GLIBC_BASE_URL="https://github.com/andyshinn/alpine-pkg-glibc/release
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
\
rm "/etc/apk/keys/andyshinn.rsa.pub" && \
rm "/etc/apk/keys/sgerrand.rsa.pub" && \
/usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true && \
echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
\
Expand Down Expand Up @@ -91,7 +91,8 @@ RUN apk add --no-cache --virtual=build-dependencies wget ca-certificates && \
rm "/tmp/"*

# Maven
# RUN apk update && apk add maven=3.3.9-r0
# as of 2016-06-12 maven apk is still in edge branch and not accessible by default
#RUN apk update && apk add maven=3.3.9-r0
ENV MAVEN_HOME="/usr/share/maven"
ENV MAVEN_VERSION="3.3.9"
RUN cd / && \
Expand All @@ -115,4 +116,4 @@ RUN npm run webpack

ENV PATH /usr/src/yasp/node_modules/pm2/bin:$PATH

CMD [ "node", "deploy.js" ]
CMD [ "npm", "start" ]
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var defaults = {
"PROXY_URLS": "", //comma separated list of proxy urls to use
"STEAM_API_HOST": "api.steampowered.com", //the list of hosts to fetch Steam API data from
"ROLE": "", //for specifying the file that should be run when deploy.js is invoked
"GROUP": "", //for specifying the group of apps that should be run when deploy.js is invoked
"MMSTATS_DATA_INTERVAL": 3, //minutes between requests for MMStats data
"DEFAULT_DELAY": 1000, // delay between API requests (default: 1000)
"SCANNER_DELAY": 300, //delay for scanner API requests (more time-sensitive)
Expand Down
6 changes: 3 additions & 3 deletions deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Deployment entry point for the application.
**/
var args = process.argv.slice(2);
var group = args[0] || process.env.GROUP;
var cp = require('child_process');
if (process.env.PROVIDER === "gce")
{
Expand All @@ -12,17 +13,16 @@ if (process.env.ROLE)
//if role variable is set just run that script
require('./svc/' + process.env.ROLE + ".js");
}
else if (args[0])
else if (group)
{
var pm2 = require('pm2');
var async = require('async');
var manifest = require('./profiles/everything.json').apps;
//if argument supplied use pm2 to run processes in that group
pm2.connect(function()
{
async.each(manifest, function start(app, cb)
{
if (args[0] === app.group)
if (group === app.group)
{
console.log(app.script, app.instances);
pm2.start(app.script,
Expand Down
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"kube": "kubectl get rc -o name --selector tier=backend | cut -d '/' -f2 | xargs -n1 kubectl rolling-update --image=yasp/yasp:latest",
"rediskeys": "redis-cli keys '*' | cut -d':' -f1 | sort | uniq -c",
"resetpicks": "redis-cli keys 'picks_*' | xargs redis-cli del",
"updateconstants": "node tasks/updateconstants"
"updateconstants": "node tasks/updateconstants",
"dockerbuild": "sudo docker build -t yasp/yasp ."
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -56,7 +57,6 @@
"jade": "^1.11.0",
"jquery": "^2.2.0",
"knex": "^0.10.0",
"material-ui": "^0.15.0-alpha.2",
"moment": "^2.11.2",
"multer": "^1.1.0",
"ndjson": "^1.4.3",
Expand Down Expand Up @@ -93,9 +93,5 @@
"supertest": "^1.1.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.12"
},
"engines": {
"node": "6.0.0",
"npm": "3.8.8"
}
}
6 changes: 3 additions & 3 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ DATETIME=$(date +%s)

if [ "$1" = "parser" ] || [[ $# -eq 0 ]]; then
gcloud compute instance-templates create parser-$DATETIME --machine-type n1-highcpu-2 --image container-vm --preemptible --boot-disk-size 10GB --boot-disk-type pd-ssd --metadata startup-script='#!/bin/bash
sudo docker run -d --name=parser --restart=always -e PROVIDER=gce -e ROLE=parser yasp/yasp:latest sh -c "node deploy.js"
sudo docker run -d --name=parser --restart=always -e PROVIDER=gce -e ROLE=parser yasp/yasp:latest sh -c "npm start"
sudo docker start parser
'
gcloud alpha compute rolling-updates start --group parser-group-1 --template parser-$DATETIME
fi

if [ "$1" = "backend" ] || [[ $# -eq 0 ]]; then
gcloud compute instance-templates create backend-$DATETIME --machine-type n1-highcpu-4 --image container-vm --preemptible --boot-disk-size 10GB --boot-disk-type pd-ssd --tags "http-server" --metadata startup-script='#!/bin/bash
sudo docker run -d --name yasp --restart=always --net=host -e PROVIDER=gce yasp/yasp:latest sh -c "node deploy.js core"
sudo docker run -d --name yasp --restart=always --net=host -e PROVIDER=gce -e GROUP=core yasp/yasp:latest sh -c "npm start"
sudo docker start yasp
'
gcloud alpha compute rolling-updates start --group backend-group-1 --template backend-$DATETIME
fi

if [ "$1" = "web" ] || [[ $# -eq 0 ]]; then
gcloud compute instance-templates create web-$DATETIME --machine-type g1-small --image container-vm --preemptible --boot-disk-size 10GB --boot-disk-type pd-ssd --tags "http-server" --metadata startup-script='#!/bin/bash
sudo docker run -d --name=web --restart=always --net=host -e FRONTEND_PORT=80 -e PROVIDER=gce -e ROLE=web yasp/yasp:latest sh -c "node deploy.js"
sudo docker run -d --name=web --restart=always --net=host -e FRONTEND_PORT=80 -e PROVIDER=gce -e ROLE=web yasp/yasp:latest sh -c "npm start"
sudo docker start web
'
gcloud alpha compute rolling-updates start --group web-group-1 --template web-$DATETIME --min-instance-update-time 180
Expand Down
6 changes: 3 additions & 3 deletions scripts/gce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ gcloud compute http-health-checks delete -q lb-check
gcloud compute instance-groups managed delete -q web-group-1
gcloud compute instance-templates delete -q web-1
gcloud compute instance-templates create web-1 --machine-type g1-small --image container-vm --preemptible --boot-disk-size 10GB --boot-disk-type pd-ssd --tags "http-server" --metadata startup-script='#!/bin/bash
sudo docker run -d --name=web --restart=always --net=host -e FRONTEND_PORT=80 -e PROVIDER=gce -e ROLE=web yasp/yasp:latest sh -c "node deploy.js"
sudo docker run -d --name=web --restart=always --net=host -e FRONTEND_PORT=80 -e PROVIDER=gce -e ROLE=web yasp/yasp:latest sh -c "npm start"
sudo docker start web
'
gcloud compute instance-groups managed create "web-group-1" --base-instance-name "web-group-1" --template "web-1" --size "0"
Expand All @@ -40,7 +40,7 @@ gcloud compute instance-groups managed set-autoscaling "web-group-1" --cool-down
gcloud compute instance-groups managed delete -q backend-group-1
gcloud compute instance-templates delete -q backend-1
gcloud compute instance-templates create backend-1 --machine-type n1-highcpu-4 --image container-vm --preemptible --boot-disk-size 10GB --boot-disk-type pd-ssd --tags "http-server" --metadata startup-script='#!/bin/bash
sudo docker run -d --name yasp --restart=always --net=host -e PROVIDER=gce yasp/yasp:latest sh -c "node deploy.js core"
sudo docker run -d --name yasp --restart=always --net=host -e PROVIDER=gce -e GROUP=core yasp/yasp:latest sh -c "npm start"
sudo docker start yasp
'
gcloud compute instance-groups managed create "backend-group-1" --base-instance-name "backend-group-1" --template "backend-1" --size "1"
Expand All @@ -49,7 +49,7 @@ gcloud compute instance-groups managed create "backend-group-1" --base-instance-
gcloud compute instance-groups managed delete -q parser-group-1
gcloud compute instance-templates delete -q parser-1
gcloud compute instance-templates create parser-1 --machine-type n1-highcpu-2 --image container-vm --preemptible --boot-disk-size 10GB --boot-disk-type pd-ssd --metadata startup-script='#!/bin/bash
sudo docker run -d --name=parser --restart=always -e PROVIDER=gce -e ROLE=parser yasp/yasp:latest sh -c "node deploy.js"
sudo docker run -d --name=parser --restart=always -e PROVIDER=gce -e ROLE=parser yasp/yasp:latest sh -c "npm start"
sudo docker start parser
'
gcloud compute instance-groups managed create "parser-group-1" --base-instance-name "parser-group-1" --template "parser-1" --size "1"
Expand Down

0 comments on commit 1078a11

Please sign in to comment.