From 1078a11e7eef2d39d3c7925a537adc902545b5f5 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 13 Jun 2016 00:30:23 +0000 Subject: [PATCH] node6 --- Dockerfile | 19 ++++++++++--------- config.js | 1 + deploy.js | 6 +++--- package.json | 8 ++------ scripts/deploy.sh | 6 +++--- scripts/gce.sh | 6 +++--- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f617adbf..ba5cacf65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" \ @@ -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 && \ \ @@ -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 / && \ @@ -115,4 +116,4 @@ RUN npm run webpack ENV PATH /usr/src/yasp/node_modules/pm2/bin:$PATH -CMD [ "node", "deploy.js" ] \ No newline at end of file +CMD [ "npm", "start" ] \ No newline at end of file diff --git a/config.js b/config.js index 658b0ab0a..444367392 100644 --- a/config.js +++ b/config.js @@ -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) diff --git a/deploy.js b/deploy.js index 47f0df51a..37e4de4f6 100644 --- a/deploy.js +++ b/deploy.js @@ -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") { @@ -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, diff --git a/package.json b/package.json index 6165eadd7..2e7b97634 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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" } } diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 5ef923192..e8204b539 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -4,7 +4,7 @@ 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 @@ -12,7 +12,7 @@ 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 @@ -20,7 +20,7 @@ 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 diff --git a/scripts/gce.sh b/scripts/gce.sh index 9e5e36d43..4c16a1d65 100644 --- a/scripts/gce.sh +++ b/scripts/gce.sh @@ -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" @@ -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" @@ -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"