Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu69 committed Nov 15, 2015
0 parents commit dc7003d
Show file tree
Hide file tree
Showing 18 changed files with 286 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs/node_modules
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
elasticsearch:
image: elasticsearch:latest
command: elasticsearch -Des.network.host=0.0.0.0
ports:
- '9200:9200'
kibana:
build: kibana/
volumes:
- ./kibana/config/kibana.yml:/opt/kibana/config/kibana.yml
ports:
- '5601:5601'
links:
- elasticsearch
fluentd:
build: fluentd/
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers
links:
- elasticsearch
ports:
- '24224:24224'
nginx:
build: nginx/
links:
- fluentd
- node_app
ports:
- '80:80'
log_driver: 'fluentd'
log_opt:
fluentd-address: localhost:24224
fluentd-tag: docker.{{.FullID}}
node_app:
build: node_app/
links:
- fluentd
ports:
- '8080:8080'
log_driver: 'fluentd'
log_opt:
fluentd-address: localhost:24224
fluentd-tag: docker.{{.FullID}}
15 changes: 15 additions & 0 deletions fluentd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM fluent/fluentd:latest

USER root
WORKDIR /
RUN apt-get update -y && apt-get install -y netcat

COPY entrypoint.sh /tmp/entrypoint.sh
RUN chmod +x /tmp/entrypoint.sh

ENV PATH /home/ubuntu/ruby/bin:$PATH
RUN gem install fluent-plugin-elasticsearch

ADD fluent.conf /fluentd/etc/fluent.conf

CMD ["sh", "-c", "/tmp/entrypoint.sh"]
9 changes: 9 additions & 0 deletions fluentd/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

while ! nc -w 1 elasticsearch 9200 > /dev/null 2>&1; do
echo "Fluentd waithing TCP connection $ELASTICSEARCH_PORT_9200_TCP_ADDR:$ELASTICSEARCH_PORT_9200_TCP_PORT..."
sleep 1
done

echo "Start fluentd"
fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT
23 changes: 23 additions & 0 deletions fluentd/fluent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<source>
type forward
port 24224
bind 0.0.0.0
</source>

# <source>
# type tail
# read_from_head true
# path /var/lib/docker/containers/*/*-json.log
# pos_file /var/log/fluentd-docker.pos
# time_format %Y-%m-%dT%H:%M:%S
# tag docker.log
# format json
# </source>

<match docker.**>
type elasticsearch
logstash_format true
host elasticsearch
port 9200
flush_interval 5s
</match>
Empty file added fluentd/plugins/.gitkeep
Empty file.
12 changes: 12 additions & 0 deletions kibana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM kibana:latest

RUN apt-get update && apt-get install -y netcat

COPY entrypoint.sh /tmp/entrypoint.sh
RUN chmod +x /tmp/entrypoint.sh

COPY config/kibana.yml /opt/kibana/config/kibana.yml

RUN kibana plugin --install elastic/sense

CMD ["/tmp/entrypoint.sh"]
76 changes: 76 additions & 0 deletions kibana/config/kibana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Kibana is served by a back end server. This controls which port to use.
port: 5601

# The host to bind the server to.
host: "0.0.0.0"

# The Elasticsearch instance to use for all your queries.
elasticsearch_url: "http://elasticsearch:9200"

# preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false,
# then the host you use to connect to *this* Kibana instance will be sent.
elasticsearch_preserve_host: true

# Kibana uses an index in Elasticsearch to store saved searches, visualizations
# and dashboards. It will create a new index if it doesn't already exist.
kibana_index: ".kibana"

# If your Elasticsearch is protected with basic auth, this is the user credentials
# used by the Kibana server to perform maintence on the kibana_index at statup. Your Kibana
# users will still need to authenticate with Elasticsearch (which is proxied thorugh
# the Kibana server)
# kibana_elasticsearch_username: user
# kibana_elasticsearch_password: pass

# If your Elasticsearch requires client certificate and key
# kibana_elasticsearch_client_crt: /path/to/your/client.crt
# kibana_elasticsearch_client_key: /path/to/your/client.key

# If you need to provide a CA certificate for your Elasticsarech instance, put
# the path of the pem file here.
# ca: /path/to/your/CA.pem

# The default application to load.
default_app_id: "discover"

# Time in milliseconds to wait for elasticsearch to respond to pings, defaults to
# request_timeout setting
# ping_timeout: 1500

# Time in milliseconds to wait for responses from the back end or elasticsearch.
# This must be > 0
request_timeout: 300000

# Time in milliseconds for Elasticsearch to wait for responses from shards.
# Set to 0 to disable.
shard_timeout: 0

# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying
# startup_timeout: 5000

# Set to false to have a complete disregard for the validity of the SSL
# certificate.
verify_ssl: true

# SSL for outgoing requests from the Kibana Server (PEM formatted)
# ssl_key_file: /path/to/your/server.key
# ssl_cert_file: /path/to/your/server.crt

# Set the path to where you would like the process id file to be created.
# pid_file: /var/run/kibana.pid

# If you would like to send the log output to a file you can set the path below.
# This will also turn off the STDOUT log output.
# log_file: ./kibana.log
# Plugins that are included in the build, and no longer found in the plugins/ folder
bundled_plugin_ids:
- plugins/dashboard/index
- plugins/discover/index
- plugins/doc/index
- plugins/kibana/index
- plugins/markdown_vis/index
- plugins/metric_vis/index
- plugins/settings/index
- plugins/table_vis/index
- plugins/vis_types/index
- plugins/visualize/index
9 changes: 9 additions & 0 deletions kibana/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

while ! nc -w 1 elasticsearch 9200 > /dev/null 2>&1; do
echo "Kibana waithing TCP connection $ELASTICSEARCH_PORT_9200_TCP_ADDR:$ELASTICSEARCH_PORT_9200_TCP_PORT..."
sleep 1
done

echo "Start Kibana"
kibana
12 changes: 12 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM nginx
ADD default.conf /etc/nginx/conf.d/default.conf

RUN mkdir -p /var/www/html
ADD index.html /var/www/html/index.html

RUN apt-get update -y && apt-get install -y netcat

COPY entrypoint.sh /tmp/entrypoint.sh
RUN chmod +x /tmp/entrypoint.sh

CMD [ "sh", "-c", "/tmp/entrypoint.sh" ]
10 changes: 10 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80 default;
server_name _;
location / {
proxy_pass http://node_app:8080;
}

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
9 changes: 9 additions & 0 deletions nginx/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

while ! nc -w 1 fluentd 24224 > /dev/null 2>&1; do
echo "Nginx waithing TCP connection $FLUENTD_PORT..."
sleep 1
done

echo "Start Nginx"
nginx -g "daemon off;"
12 changes: 12 additions & 0 deletions nginx/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>nginx</title>
<link rel="stylesheet" href="">
</head>
<body>
Hello nginx
</body>
</html>
13 changes: 13 additions & 0 deletions node_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:latest
EXPOSE 8080

RUN apt-get update -y && apt-get install -y netcat

COPY entrypoint.sh /tmp/entrypoint.sh
RUN chmod +x /tmp/entrypoint.sh

RUN mkdir -p app
ADD app/ /app
RUN cd /app && npm i

CMD [ "sh", "-c", "/tmp/entrypoint.sh" ]
3 changes: 3 additions & 0 deletions node_app/app/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
12 changes: 12 additions & 0 deletions node_app/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'
import express from 'express';
const app = express();
const port = 8080

app.get('/', (req, res) => {
res.send('Hello World!');
});

var server = app.listen(port, () => {
console.log(`Example app listening at http:\/\/localhost:${port}`);
});
19 changes: 19 additions & 0 deletions node_app/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "sample",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"start": "babel-node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"express": "^4.13.3"
},
"devDependencies": {
"babel-cli": "^6.1.18",
"babel-preset-es2015": "^6.1.18"
}
}
9 changes: 9 additions & 0 deletions node_app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

while ! nc -w 1 fluentd 24224 > /dev/null 2>&1; do
echo "NodeJS Application waithing TCP connection $FLUENTD_PORT..."
sleep 1
done

echo "Start NodeJS Application"
cd /app && npm start

0 comments on commit dc7003d

Please sign in to comment.