Skip to content

Commit

Permalink
Merge pull request #2 from jonbrouse/refactor-alpine-docker-compose-v2
Browse files Browse the repository at this point in the history
Refactor alpine docker compose v2
  • Loading branch information
jonbrouse committed Apr 1, 2016
2 parents af14fe8 + 4ab3e92 commit 693ac60
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 174 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ELK Docker Containers
This repo contains the configuration files and Dockerfiles to build individual Elasticsearch, Logstash and Kibana containers. You can use Docker Compose to build and run the containers.
This repo contains the configuration files and Dockerfiles to build individual Elasticsearch, Logstash and Kibana containers with a lightweight Alpine based image. You can use Docker Compose to build and run the containers.

## Prerequisites

You will need to have [Docker](https://docs.docker.com) and [Docker Compose](https://docs.docker.com/compose/install/) installed. If you are using a Mac check out [Boot2Docker](http://boot2docker.io/).
You will need to have [Docker](https://docs.docker.com) and [Docker Compose](https://docs.docker.com/compose/install/) installed.

## Up and Running
Create a Logstash configuration file:
Expand All @@ -28,8 +28,6 @@ This stack takes advantage of Volume mounting to facilitate quick configuration

docker-compose restart logstash

If you decide to use additional ports you will have to add them to ```docker-compose-common.yml``` in the Logstash definition.

### Data Persistance

In order for your Elasticsearch data to persist the data directory is mounted at:
Expand All @@ -44,17 +42,20 @@ You can quickly enable HTTPS on the Nginx container by adding your certs the ```
docker-compose restart nginx

## Versions
Elasticsearch and Logstash containers are built with a [Java 8 container from my Docker Hub account.](https://registry.hub.docker.com/u/jonbrouse/docker-java/dockerfile/)
Elasticsearch, Logstash and Kibana containers are built with an official Java image.

- Elasticsearch Version 1.51
- Logstash Version 1.50
- Kibana Version 4.0.2
- Elasticsearch Version 2.3.0
- Logstash Version 2.3.0
- Kibana Version 4.5.0

## Notes
I added a `tty=true` to the Logstash launch options because it kept immediately shutting down after start up completed.

Elasticsearch is run as root, which is not recommended.

### Resources

I used the following resources when creating this stack:
- [Nathan LeClaire's Automating Docker Logging](http://nathanleclaire.com/blog/2015/04/27/automating-docker-logging-elasticsearch-logstash-kibana-and-logspout/)
- [Evan Hazlett's Logging with ELK and Docker](http://evanhazlett.com/2014/11/Logging-with-ELK-and-Docker/)
- [Groob's "A tiny Kibana DOcker container"](http://groob.io/posts/kibana-alpine/)
28 changes: 0 additions & 28 deletions docker-compose-build.yml

This file was deleted.

22 changes: 0 additions & 22 deletions docker-compose-common.yml

This file was deleted.

66 changes: 38 additions & 28 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
elasticsearch:
image: jonbrouse/elk:elasticsearch
extends:
file: docker-compose-common.yml
service: elasticsearch
volumes:
- ./elasticsearch/volumes/esdata/:/opt/elasticsearch/data
logstash:
image: jonbrouse/elk:logstash
extends:
file: docker-compose-common.yml
service: logstash
links:
- elasticsearch
kibana:
image: jonbrouse/elk:kibana
extends:
file: docker-compose-common.yml
service: kibana
links:
- elasticsearch
nginx:
build: nginx
extends:
file: docker-compose-common.yml
service: nginx
links:
- kibana
version: '2'
services:
elasticsearch:
hostname: elasticsearch
image: jonbrouse/elk:elasticsearch
build: elasticsearch
command: -Des.insecure.allow.root=true
volumes:
- ./elasticsearch/volumes/esdata/:/opt/elasticsearch/data
logstash:
hostname: logstash
image: jonbrouse/elk:logstash
build: logstash
ports:
- "24642:24642"
command: -f /etc/logstash.conf
tty: true
volumes:
- ./logstash/assets/logstash.conf:/etc/logstash.conf
links:
- elasticsearch
kibana:
hostname: kibana
image: jonbrouse/elk:kibana
build: kibana
links:
- elasticsearch
nginx:
hostname: nginx
image: nginx:stable-alpine
links:
- kibana
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/assets/certs:/etc/nginx/certs
- ./nginx/assets/nginx.conf:/etc/nginx/nginx.conf
13 changes: 5 additions & 8 deletions elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
FROM jonbrouse/java:8
FROM java:8-alpine

RUN apt-get update && \
apt-get install -y curl && \
apt-get autoclean && \
apt-get --purge -y autoremove
RUN apk add --update curl tar && \
rm -rf /var/cache/apk/*

ENV HOME_DIR /opt
ENV VERSION 1.5.1
ENV VERSION 2.3.0

WORKDIR ${HOME_DIR}

RUN curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${VERSION}.tar.gz && \
RUN curl -O https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${VERSION}/elasticsearch-${VERSION}.tar.gz && \
tar -xvf elasticsearch-${VERSION}.tar.gz && \
rm -rf elasticsearch-${VERSION}.tar.gz && \
ln -s elasticsearch-${VERSION} elasticsearch
# elasticsearch/bin/plugin -install lmenezes/elasticsearch-kopf

COPY assets/elasticsearch.yml /opt/elasticsearch/config/elasticsearch.yml

Expand Down
22 changes: 11 additions & 11 deletions kibana/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
FROM debian:jessie
MAINTAINER Jon Brouse @jonbrouse
FROM java:8-alpine

RUN apt-get update && \
apt-get install -y curl && \
apt-get autoclean && \
apt-get --purge -y autoremove

ENV VERSION 4.0.2
ENV KIBANA_VERSION 4.5.0

WORKDIR /opt

RUN curl -O https://download.elastic.co/kibana/kibana/kibana-${VERSION}-linux-x64.tar.gz && \
tar -xvf kibana-${VERSION}-linux-x64.tar.gz && \
rm -rf kibana-${VERSION}-linux-x64.tar.gz && \
ln -s kibana-${VERSION}-linux-x64 kibana
RUN apk add --update nodejs curl tar && \
curl -LO https://download.elastic.co/kibana/kibana/kibana-${KIBANA_VERSION}-linux-x64.tar.gz && \
tar -xvf kibana-${KIBANA_VERSION}-linux-x64.tar.gz && \
rm kibana-${KIBANA_VERSION}-linux-x64/node/bin/node && \
rm kibana-${KIBANA_VERSION}-linux-x64/node/bin/npm && \
ln -s /usr/bin/node /opt/kibana-${KIBANA_VERSION}-linux-x64/node/bin/node && \
ln -s /usr/bin/npm /opt/kibana-${KIBANA_VERSION}-linux-x64/node/bin/npm && \
rm -rf kibana-${KIBANA_VERSION}-linux-x64.tar.gz /var/cache/apk/* && \
ln -s kibana-${KIBANA_VERSION}-linux-x64 kibana

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

Expand Down
14 changes: 5 additions & 9 deletions logstash/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
FROM jonbrouse/java:8

RUN apt-get update && \
apt-get install -y curl && \
apt-get autoclean && \
apt-get --purge -y autoremove
FROM java:8-alpine

ENV HOME_DIR /opt
ENV VERSION 1.5.0
ENV VERSION 2.3.0

WORKDIR ${HOME_DIR}

RUN curl -O https://download.elasticsearch.org/logstash/logstash/logstash-${VERSION}.tar.gz && \
RUN apk add --update bash curl tar && \
curl -O https://download.elastic.co/logstash/logstash/logstash-${VERSION}.tar.gz && \
tar -xvf logstash-${VERSION}.tar.gz && \
rm -rf logstash-${VERSION}.tar.gz && \
rm -rf logstash-${VERSION}.tar.gz /var/cache/apk/* && \
ln -s logstash-${VERSION} logstash

COPY assets/logstash.conf /etc/logstash.conf
Expand Down
11 changes: 0 additions & 11 deletions nginx/Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions nginx/assets/default-ssl-example.conf

This file was deleted.

17 changes: 0 additions & 17 deletions nginx/assets/default.conf

This file was deleted.

79 changes: 79 additions & 0 deletions nginx/assets/nginx-ssl-example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
return 301 https://$host$request_uri;
server_name localhost;

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

server {

listen 443;

ssl_certificate /etc/nginx/certs/example_com.full_chain.pem;
ssl_certificate_key /etc/nginx/certs/example_com.key;

ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;

location / {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://kibana:5601;
proxy_read_timeout 90;

proxy_redirect http://kibana:5601 http://$host;
}

}

}
Loading

0 comments on commit 693ac60

Please sign in to comment.