about summary refs log tree commit diff
path: root/compose
diff options
context:
space:
mode:
Diffstat (limited to 'compose')
-rw-r--r--compose/app/Dockerfile5
-rw-r--r--compose/app/app.py29
-rw-r--r--compose/app/requirements.txt2
-rw-r--r--compose/es/Dockerfile5
-rw-r--r--compose/es/docker-compose.yml13
-rw-r--r--compose/es/kibana.yml5
-rw-r--r--compose/monitoring/prometheus/prometheus.yml40
-rw-r--r--compose/nginx/Dockerfile4
-rw-r--r--compose/nginx/conf.d/dybiec.info.conf168
-rw-r--r--compose/nginx/nginx.conf31
-rw-r--r--compose/nginx/static-html/index.html1
11 files changed, 303 insertions, 0 deletions
diff --git a/compose/app/Dockerfile b/compose/app/Dockerfile
new file mode 100644
index 0000000..8e67d74
--- /dev/null
+++ b/compose/app/Dockerfile
@@ -0,0 +1,5 @@
+FROM python:3.4-alpine
+ADD . /code
+WORKDIR /code
+RUN pip install -r requirements.txt
+CMD ["python", "app.py"]
diff --git a/compose/app/app.py b/compose/app/app.py
new file mode 100644
index 0000000..9bf5d90
--- /dev/null
+++ b/compose/app/app.py
@@ -0,0 +1,29 @@
+import time
+
+import redis
+from flask import Flask
+
+
+app = Flask(__name__)
+cache = redis.Redis(host='redis', port=6379)
+
+
+def get_hit_count():
+    retries = 5
+    while True:
+        try:
+            return cache.incr('hits')
+        except redis.exceptions.ConnectionError as exc:
+            if retries == 0:
+                raise exc
+            retries -= 1
+            time.sleep(0.5)
+
+
+@app.route('/')
+def hello():
+    count = get_hit_count()
+    return 'Hello from this site! I have been seen {} times.\n'.format(count)
+
+if __name__ == "__main__":
+    app.run(host="0.0.0.0", debug=True)
diff --git a/compose/app/requirements.txt b/compose/app/requirements.txt
new file mode 100644
index 0000000..1a5dc97
--- /dev/null
+++ b/compose/app/requirements.txt
@@ -0,0 +1,2 @@
+flask
+redis
diff --git a/compose/es/Dockerfile b/compose/es/Dockerfile
new file mode 100644
index 0000000..8e67d74
--- /dev/null
+++ b/compose/es/Dockerfile
@@ -0,0 +1,5 @@
+FROM python:3.4-alpine
+ADD . /code
+WORKDIR /code
+RUN pip install -r requirements.txt
+CMD ["python", "app.py"]
diff --git a/compose/es/docker-compose.yml b/compose/es/docker-compose.yml
new file mode 100644
index 0000000..3edf4c0
--- /dev/null
+++ b/compose/es/docker-compose.yml
@@ -0,0 +1,13 @@
+version: '3'
+services:
+  elasticsearch:
+    image: "docker.elastic.co/elasticsearch/elasticsearch:6.3.1"
+    environment:
+    - "discovery.type=single-node"
+    #ports:
+    # - "9200:9200"
+    # - "9300:9300"
+  kibana:
+    image: "docker.elastic.co/kibana/kibana:6.3.1"
+    ports:
+    - "5601:5601"
diff --git a/compose/es/kibana.yml b/compose/es/kibana.yml
new file mode 100644
index 0000000..59691ca
--- /dev/null
+++ b/compose/es/kibana.yml
@@ -0,0 +1,5 @@
+server.name: kibana
+server.host: "0"
+elasticsearch.url: http://elasticsearch:9200
+xpack.monitoring.ui.container.elasticsearch.enabled: true
+xpack.monitoring.enabled: true
diff --git a/compose/monitoring/prometheus/prometheus.yml b/compose/monitoring/prometheus/prometheus.yml
new file mode 100644
index 0000000..2903091
--- /dev/null
+++ b/compose/monitoring/prometheus/prometheus.yml
@@ -0,0 +1,40 @@
+# my global config
+global:
+  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
+  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
+  # scrape_timeout is set to the global default (10s).
+
+  # Attach these labels to any time series or alerts when communicating with
+  # external systems (federation, remote storage, Alertmanager).
+  external_labels:
+      monitor: 'codelab-monitor'
+
+# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
+rule_files:
+  # - "first.rules"
+  # - "second.rules"
+
+# A scrape configuration containing exactly one endpoint to scrape:
+# Here it's Prometheus itself.
+scrape_configs:
+  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
+  - job_name: 'prometheus'
+
+    # metrics_path defaults to '/metrics'
+    # scheme defaults to 'http'.
+
+    static_configs:
+      - targets: ['localhost:9090']
+
+  - job_name: 'docker'
+         # metrics_path defaults to '/metrics'
+         # scheme defaults to 'http'.
+
+    static_configs:
+      - targets: ['dockerhost:9323']
+  - job_name: 'cadvisor'
+         # metrics_path defaults to '/metrics'
+         # scheme defaults to 'http'.
+
+    static_configs:
+      - targets: ['cadvisor:8080']
diff --git a/compose/nginx/Dockerfile b/compose/nginx/Dockerfile
new file mode 100644
index 0000000..fcca1df
--- /dev/null
+++ b/compose/nginx/Dockerfile
@@ -0,0 +1,4 @@
+FROM nginx:1.15.8-alpine
+COPY static-html /usr/share/nginx/html
+COPY conf.d /etc/nginx/conf.d
+COPY nginx.conf /etc/nginx/nginx.conf
diff --git a/compose/nginx/conf.d/dybiec.info.conf b/compose/nginx/conf.d/dybiec.info.conf
new file mode 100644
index 0000000..90cd471
--- /dev/null
+++ b/compose/nginx/conf.d/dybiec.info.conf
@@ -0,0 +1,168 @@
+server {
+  listen 80;
+  listen 443 ssl;
+  server_name .dybiec.info;
+
+  ssl_certificate     /etc/letsencrypt/live/dybiec.info/fullchain.pem;
+  ssl_certificate_key /etc/letsencrypt/live/dybiec.info/privkey.pem;
+  
+  location / {
+    root /usr/share/nginx/html;
+    index index.html;
+  }
+
+}
+server {
+  listen 80;
+  listen 443 ssl;
+  server_name cnt.dybiec.info;
+
+  ssl_certificate     /etc/letsencrypt/live/dybiec.info/fullchain.pem;
+  ssl_certificate_key /etc/letsencrypt/live/dybiec.info/privkey.pem;
+  
+  location / {
+    proxy_pass http://localhost:5004;
+  }
+}
+server {
+  listen 80;
+  listen 443 ssl;
+  server_name registry.dybiec.info;
+
+  ssl_certificate     /etc/letsencrypt/live/dybiec.info/fullchain.pem;
+  ssl_certificate_key /etc/letsencrypt/live/dybiec.info/privkey.pem;
+  
+  location / {
+    proxy_pass http://localhost:5000;
+    proxy_set_header  Host              $http_host;   # required for docker client's sake
+    proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP
+    proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
+    proxy_set_header  X-Forwarded-Proto $scheme;
+    client_max_body_size 0;
+  }
+}
+server {
+       listen         80;
+       server_name    git.dybiec.info;
+       return         301 https://$server_name$request_uri;
+}
+server {
+  listen 443 ssl;
+  server_name git.dybiec.info;
+
+  ssl_certificate     /etc/letsencrypt/live/dybiec.info/fullchain.pem;
+  ssl_certificate_key /etc/letsencrypt/live/dybiec.info/privkey.pem;
+  
+  location / {
+    proxy_pass http://localhost:5001;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header Host $http_host;
+    proxy_redirect off;
+    proxy_http_version 1.1;
+  }
+  gzip_proxied any;
+  gzip_types
+    text/css
+    text/javascript
+    text/xml
+    text/plain
+    application/javascript
+    application/x-javascript
+    application/json;
+
+}
+server {
+       listen         80;
+       server_name    grafana.dybiec.info;
+       return         301 https://$server_name$request_uri;
+}
+server {
+  listen 443 ssl;
+  server_name grafana.dybiec.info;
+
+  ssl_certificate     /etc/letsencrypt/live/dybiec.info/fullchain.pem;
+  ssl_certificate_key /etc/letsencrypt/live/dybiec.info/privkey.pem;
+  
+  location / {
+    proxy_pass http://localhost:5002;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header Host $http_host;
+    proxy_redirect off;
+    proxy_http_version 1.1;
+  }
+  gzip_proxied any;
+  gzip_types
+    text/css
+    text/javascript
+    text/xml
+    text/plain
+    application/javascript
+    application/x-javascript
+    application/json;
+
+}
+server {
+       listen         80;
+       server_name    prometheus.dybiec.info;
+       return         301 https://$server_name$request_uri;
+}
+server {
+  listen 443 ssl;
+  server_name prometheus.dybiec.info;
+
+  ssl_certificate     /etc/letsencrypt/live/dybiec.info/fullchain.pem;
+  ssl_certificate_key /etc/letsencrypt/live/dybiec.info/privkey.pem;
+  
+  location / {
+    proxy_pass http://localhost:5003;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header Host $http_host;
+    proxy_redirect off;
+    proxy_http_version 1.1;
+  }
+  gzip_proxied any;
+  gzip_types
+    text/css
+    text/javascript
+    text/xml
+    text/plain
+    application/javascript
+    application/x-javascript
+    application/json;
+
+}
+server {
+       listen         80;
+       server_name    octoprint.dybiec.info;
+       return         301 https://$server_name$request_uri;
+}
+server {
+  listen 443 ssl;
+  server_name octoprint.dybiec.info;
+
+  ssl_certificate     /etc/letsencrypt/live/dybiec.info/fullchain.pem;
+  ssl_certificate_key /etc/letsencrypt/live/dybiec.info/privkey.pem;
+  
+  location / {
+    proxy_pass http://192.168.255.6/;
+    proxy_redirect off;
+    proxy_http_version 1.1;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header Host $http_host;
+    proxy_set_header X-Real-IP $remote_addr;
+    proxy_set_header Upgrade $http_upgrade;
+    proxy_set_header Connection "Upgrade";
+
+    client_max_body_size 0;    
+  }
+  gzip_proxied any;
+  gzip_types
+    text/css
+    text/javascript
+    text/xml
+    text/plain
+    application/javascript
+    application/x-javascript
+    application/json;
+
+}
diff --git a/compose/nginx/nginx.conf b/compose/nginx/nginx.conf
new file mode 100644
index 0000000..aa6cbd7
--- /dev/null
+++ b/compose/nginx/nginx.conf
@@ -0,0 +1,31 @@
+user  nginx;
+worker_processes  1;
+
+error_log  /var/log/nginx/error.log warn;
+pid        /var/run/nginx.pid;
+
+
+events {
+    worker_connections  1024;
+}
+
+
+http {
+    include       /etc/nginx/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  /var/log/nginx/access.log  main;
+
+    sendfile        on;
+    tcp_nopush     on;
+
+    keepalive_timeout  65;
+
+    gzip  on;
+
+    include /etc/nginx/conf.d/*.conf;
+}
diff --git a/compose/nginx/static-html/index.html b/compose/nginx/static-html/index.html
new file mode 100644
index 0000000..ce01362
--- /dev/null
+++ b/compose/nginx/static-html/index.html
@@ -0,0 +1 @@
+hello