forked from thewildcast/curso-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11cfb2f
Showing
17 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: "2" | ||
|
||
services: | ||
rng: | ||
build: rng | ||
image: ${REGISTRY_SLASH}rng${COLON_TAG} | ||
ports: | ||
- "8001:80" | ||
|
||
hasher: | ||
build: hasher | ||
image: ${REGISTRY_SLASH}hasher${COLON_TAG} | ||
ports: | ||
- "8002:80" | ||
|
||
webui: | ||
build: webui | ||
image: ${REGISTRY_SLASH}webui${COLON_TAG} | ||
ports: | ||
- "8000:80" | ||
volumes: | ||
- "./webui/files/:/files/" | ||
|
||
redis: | ||
image: redis | ||
|
||
worker: | ||
build: worker | ||
image: ${REGISTRY_SLASH}worker${COLON_TAG} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
version: "2" | ||
|
||
services: | ||
|
||
rng: | ||
build: rng | ||
ports: | ||
- "8001:80" | ||
logging: | ||
driver: gelf | ||
options: | ||
gelf-address: udp://localhost:12201 | ||
|
||
hasher: | ||
build: hasher | ||
ports: | ||
- "8002:80" | ||
logging: | ||
driver: gelf | ||
options: | ||
gelf-address: udp://localhost:12201 | ||
|
||
webui: | ||
build: webui | ||
ports: | ||
- "8000:80" | ||
volumes: | ||
- "./webui/files/:/files/" | ||
logging: | ||
driver: gelf | ||
options: | ||
gelf-address: udp://localhost:12201 | ||
|
||
redis: | ||
image: redis | ||
logging: | ||
driver: gelf | ||
options: | ||
gelf-address: udp://localhost:12201 | ||
|
||
worker: | ||
build: worker | ||
logging: | ||
driver: gelf | ||
options: | ||
gelf-address: udp://localhost:12201 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: "2" | ||
|
||
services: | ||
rng: | ||
build: rng | ||
ports: | ||
- "8001:80" | ||
|
||
hasher: | ||
build: hasher | ||
ports: | ||
- "8002:80" | ||
|
||
webui: | ||
build: webui | ||
ports: | ||
- "8000:80" | ||
volumes: | ||
- "./webui/files/:/files/" | ||
|
||
redis: | ||
image: redis | ||
|
||
worker: | ||
build: worker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM ruby:alpine | ||
RUN apk add --update build-base curl | ||
RUN gem install sinatra | ||
RUN gem install thin | ||
ADD hasher.rb / | ||
CMD ["ruby", "hasher.rb"] | ||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'digest' | ||
require 'sinatra' | ||
require 'socket' | ||
|
||
set :bind, '0.0.0.0' | ||
set :port, 80 | ||
|
||
post '/' do | ||
# Simulate a bit of delay | ||
sleep 0.1 | ||
content_type 'text/plain' | ||
"#{Digest::SHA2.new().update(request.body.read)}" | ||
end | ||
|
||
get '/' do | ||
"HASHER running on #{Socket.gethostname}\n" | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM python:alpine | ||
RUN pip install Flask | ||
COPY rng.py / | ||
CMD ["python", "rng.py"] | ||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from flask import Flask, Response | ||
import os | ||
import socket | ||
import time | ||
|
||
app = Flask(__name__) | ||
|
||
# Enable debugging if the DEBUG environment variable is set and starts with Y | ||
app.debug = os.environ.get("DEBUG", "").lower().startswith('y') | ||
|
||
hostname = socket.gethostname() | ||
|
||
urandom = os.open("/dev/urandom", os.O_RDONLY) | ||
|
||
|
||
@app.route("/") | ||
def index(): | ||
return "RNG running on {}\n".format(hostname) | ||
|
||
|
||
@app.route("/<int:how_many_bytes>") | ||
def rng(how_many_bytes): | ||
# Simulate a little bit of delay | ||
time.sleep(0.1) | ||
return Response( | ||
os.read(urandom, how_many_bytes), | ||
content_type="application/octet-stream") | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=80, threaded=False) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM node:4-slim | ||
RUN npm install express | ||
RUN npm install redis | ||
COPY files/ /files/ | ||
COPY webui.js / | ||
CMD ["node", "webui.js"] | ||
EXPOSE 80 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>DockerCoin Miner WebUI</title> | ||
<link rel="stylesheet" type="text/css" href="rickshaw.min.css"> | ||
<style> | ||
#graph { | ||
background-color: #eee; | ||
width: 800px; | ||
height: 400px; | ||
} | ||
#tweet { | ||
color: royalblue; | ||
} | ||
</style> | ||
<script src="jquery.js"></script> | ||
<script src="d3.min.js"></script> | ||
<script src="rickshaw.min.js"></script> | ||
<script> | ||
|
||
String.prototype.format = function () { | ||
var args = arguments; | ||
return this.replace(/\{(\d+)\}/g, function (m, n) { return args[n]; }); | ||
}; | ||
|
||
var series = []; | ||
var points = [] | ||
var graph = null; | ||
|
||
function refresh () { | ||
$.ajax({ url: "json" }).done(function (data) { | ||
series.push(data); | ||
while (series.length < 250) { | ||
data = JSON.parse(JSON.stringify(data)); | ||
data.now -= 1; | ||
series.unshift(data); | ||
} | ||
while (series.length > 250) { | ||
series.shift(); | ||
} | ||
while (points.length > 0) { | ||
points.pop(); | ||
} | ||
var speed; | ||
for (var i=0; i<series.length-1; i++) { | ||
// Compute instantaneous speed | ||
var s1 = series[i]; | ||
var s2 = series[i+1]; | ||
speed = (s2.hashes-s1.hashes)/(s2.now-s1.now); | ||
points.push({ x: s2.now, y: speed }); | ||
} | ||
$("#speed").text("~" + speed.toFixed(1) + " hashes/second"); | ||
var msg = ("I'm attending a @docker orchestration workshop, " | ||
+ "and my #DockerCoins mining rig is crunching " | ||
+ speed.toFixed(1) + " hashes/second! W00T!"); | ||
$("#tweet").attr( | ||
"href", | ||
"https://twitter.com/intent/tweet?text="+encodeURIComponent(msg) | ||
); | ||
if (graph == null) { | ||
graph = new Rickshaw.Graph({ | ||
renderer: "area", | ||
stroke: true, | ||
width: 800, | ||
height: 400, | ||
element: $("#graph")[0], | ||
preserve: true, | ||
series: [ | ||
{ name: "Coins", | ||
color: "steelblue", | ||
data: points | ||
} | ||
] | ||
}); | ||
graph.render(); | ||
var yAxis = new Rickshaw.Graph.Axis.Y({ | ||
graph: graph, | ||
tickFormat: Rickshaw.Fixtures.Number.formatKMBT, | ||
ticksTreatment: "glow" | ||
}); | ||
yAxis.render(); | ||
} else { | ||
graph.update(); | ||
$("text").css({ | ||
"font-size": "15px", | ||
"font-weight": "normal", | ||
"opacity": 0.5, | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
$(function () { | ||
setInterval(refresh, 1000); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<h1>DockerCoin Miner WebUI</h1> | ||
|
||
<div id="graph"></div> | ||
|
||
<h2> | ||
Current mining speed: | ||
<span id="speed">-</span> | ||
<a id="tweet" href="#">(Tweet this!)</a> | ||
</h2> | ||
|
||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
jquery-1.11.3.min.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var express = require('express'); | ||
var app = express(); | ||
var redis = require('redis'); | ||
|
||
var client = redis.createClient(6379, 'redis'); | ||
client.on("error", function (err) { | ||
console.error("Redis error", err); | ||
}); | ||
|
||
app.get('/', function (req, res) { | ||
res.redirect('/index.html'); | ||
}); | ||
|
||
app.get('/json', function (req, res) { | ||
client.hlen('wallet', function (err, coins) { | ||
client.get('hashes', function (err, hashes) { | ||
var now = Date.now() / 1000; | ||
res.json( { | ||
coins: coins, | ||
hashes: hashes, | ||
now: now | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
app.use(express.static('files')); | ||
|
||
var server = app.listen(80, function () { | ||
console.log('WEBUI running on port 80'); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM python:alpine | ||
RUN pip install redis | ||
RUN pip install requests | ||
COPY worker.py / | ||
CMD ["python", "worker.py"] |
Oops, something went wrong.