This commit is contained in:
Tommy Parnell
2017-01-13 12:46:41 -05:00
parent 9d981341c0
commit 7af404cac7
13 changed files with 68 additions and 39 deletions

View File

@@ -1,13 +1,15 @@
FROM microsoft/dotnet:latest FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app WORKDIR /app
ADD project.json project.json
RUN ["dotnet", "restore"] RUN ["dotnet", "restore"]
RUN ["dotnet", "build"] ADD . .
EXPOSE 5000/tcp RUN ["dotnet", "build", "-c", "Release"]
CMD ["dotnet", "run", "--server.urls", "http://*:5000"] EXPOSE 80/tcp
CMD ["dotnet", "run", "-c", "Release", "--server.urls", "http://*:80"]

View File

@@ -8,5 +8,4 @@ RUN dotnet restore
# copy and build everything else # copy and build everything else
ADD . . ADD . .
RUN dotnet build -C Release ENTRYPOINT ["dotnet", "run", "-c", "Release"]
ENTRYPOINT ["dotnet", "run", "-C", "Release"]

View File

@@ -8,6 +8,7 @@ namespace Worker
{ {
public class Program public class Program
{ {
static Random rand = new Random();
static HttpClient httpclient = new HttpClient(); static HttpClient httpclient = new HttpClient();
public static void Main(string[] args) public static void Main(string[] args)
{ {
@@ -17,19 +18,20 @@ namespace Worker
{ {
while(true) while(true)
{ {
try // try
{ // {
var bytes = await httpclient.GetByteArrayAsync("http://gen/8"); var bytes = await httpclient.GetByteArrayAsync("http://gen/8");
var results = await httpclient.PostAsync("http://hashr/hashme", new ByteArrayContent(bytes)); var results = await httpclient.PostAsync("http://hashr/hashme", new ByteArrayContent(bytes));
results.EnsureSuccessStatusCode(); results.EnsureSuccessStatusCode();
var hashResults = await results.Content.ReadAsStringAsync(); var hashResults = await results.Content.ReadAsStringAsync();
var dbResult = await httpclient.GetStringAsync($"http://store/store?dt={DateTime.Now.ToString()}"); await httpclient.GetStringAsync($"http://store/store");
await Task.Delay(1000); await Task.Delay(rand.Next(100, 1000));
} // }
catch(Exception e) // catch(Exception e)
{ // {
Console.WriteLine(e.Message); // Console.WriteLine("WORKER FAILED");
} // Console.WriteLine(e.Message);
// }
} }
} }
} }

31
docker-compose.yml Normal file
View File

@@ -0,0 +1,31 @@
version: "2"
services:
gen:
build: gen
ports:
- "8001:80"
hashr:
build: Hashr
ports:
- "8002:80"
ui:
build: ui
ports:
- "8000:80"
links:
- store
store:
build: store
ports:
- "8003:80"
worker:
build: worker
links:
- hashr
- gen
- store

View File

@@ -18,7 +18,6 @@ def index():
@app.route("/<int:how_many_bytes>") @app.route("/<int:how_many_bytes>")
def gen(how_many_bytes): def gen(how_many_bytes):
time.sleep(0.1)
return Response( return Response(
os.read(urandom, how_many_bytes), os.read(urandom, how_many_bytes),
content_type="application/octet-stream") content_type="application/octet-stream")

View File

@@ -1,9 +1,7 @@
FROM ruby:alpine FROM ruby:alpine
RUN apk add --update build-base RUN apk add --update build-base
RUN gem install bundle RUN gem install sinatra
RUN gem install thin RUN gem install thin
ADD Gemfile . ADD app.rb /
RUN bundle CMD ["ruby", "app.rb"]
ADD . .
CMD ["bundle", "exec", "thin", "start"]
EXPOSE 80 EXPOSE 80

View File

@@ -1,3 +1,3 @@
source "https://rubygems.org" source "https://rubygems.org"
gem 'sinatra' gem 'sinatra'
gem 'nokogiri' gem 'thin'

View File

@@ -1,7 +1,8 @@
require 'sinatra' require 'sinatra'
require 'date' require 'date'
require 'json' require 'json'
set :bind, '0.0.0.0'
set :port, 80
get '/' do get '/' do
content_type :json content_type :json
getData.to_json getData.to_json

View File

@@ -2,9 +2,9 @@ FROM node:boron-wheezy
RUN npm install -g bower RUN npm install -g bower
ADD package.json . ADD package.json .
RUN npm install RUN npm install
ADD bower.json ADD bower.json bower.json
RUN bower install RUN bower install --allow-root
ADD . . ADD . .
EXPOSE 3000 EXPOSE 80
CMD ["npm", "run", "start"] CMD ["npm", "run", "start"]

View File

@@ -16,7 +16,7 @@ app.locals.ENV = env;
app.locals.ENV_DEVELOPMENT = env == 'development'; app.locals.ENV_DEVELOPMENT = env == 'development';
// view engine setup // view engine setup
app.set('port', process.env.PORT || 80);
app.set('views', path.join(__dirname, 'views')); app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs'); app.set('view engine', 'ejs');

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env node #!/usr/bin/env node
var app = require('../app'); var app = require('../app');
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() { var server = app.listen(app.get('port'), function() {
console.log('Express server listening on port ' + server.address().port); console.log('Express server listening on port ' + server.address().port);
}); });

View File

@@ -9,14 +9,13 @@ router.get('/', function(req, res) {
}); });
router.get('/db', (req, res)=>{ router.get('/db', (req, res)=>{
// request('http://store/', function (error, response, body) { request('http://store/', function (error, response, body) {
// if (!error && response.statusCode == 200) { if (!error && response.statusCode == 200) {
// console.log(body) // Show the HTML for the Google homepage. console.log(body) // Show the HTML for the Google homepage.
// } }
// res.set('Content-Type', 'application/json'); res.set('Content-Type', 'application/json');
// return res.send(200, body); return res.send(200, body);
// }) });
res.json([ { date: '2017-01-01 10:01', value: 20 }, { date: '2017-01-01 11:00', value: 60 }]);
}); });
module.exports = router; module.exports = router;

View File

@@ -13,7 +13,7 @@
var data = [] var data = []
var graph = new Rickshaw.Graph({ var graph = new Rickshaw.Graph({
element: document.querySelector("#chart"), element: document.querySelector("#chart"),
renderer: 'line', renderer: 'area',
series: [{ series: [{
data: data, data: data,
color: 'steelblue' color: 'steelblue'