forked from cybertec-postgresql/pgwatch2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
79 lines (65 loc) · 3.74 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
FROM ubuntu:16.04
RUN apt-get -q update \
&& apt-get -qy install wget apt-transport-https vim git supervisor postgresql postgresql-plpython-9.5 libfontconfig python3-pip python-pip \
&& locale-gen "en_US.UTF-8" && apt autoremove -y \
&& pg_dropcluster 9.5 main ; pg_createcluster --locale en_US.UTF-8 9.5 main \
&& echo "include = 'pgwatch_postgresql.conf'" >> /etc/postgresql/9.5/main/postgresql.conf
### Download and install external components
# Grafana [https://grafana.com/grafana/download]
# latest ver.: curl -so- https://api.github.com/repos/grafana/grafana/tags | grep -Eo '"v[0-9\.]+"' | grep -Eo '[0-9\.]+' | sort -nr | head -1
# Influxdb [https://portal.influxdata.com/downloads]
# latest ver.: curl -so- https://api.github.com/repos/influxdata/influxdb/tags | grep -Eo '"v[0-9\.]+"' | grep -Eo '[0-9\.]+' | sort -nr | head -1
RUN wget -q -O grafana.deb https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_5.2.2_amd64.deb \
&& wget -q -O - https://dl.influxdata.com/influxdb/releases/influxdb_1.6.2_amd64.deb > influxdb_amd64.deb \
&& dpkg -i grafana.deb && rm grafana.deb \
&& dpkg -i influxdb_amd64.deb && rm influxdb_amd64.deb \
&& sed -i 's/\# query-log-enabled = true/query-log-enabled = false/' /etc/influxdb/influxdb.conf \
&& sed -i 's/\# \[monitor\]/\[monitor\]/' /etc/influxdb/influxdb.conf \
&& sed -i 's/\# store-enabled = true/store-enabled = false/' /etc/influxdb/influxdb.conf \
&& sed -i 's/\# \[http\]/\[http\]/' /etc/influxdb/influxdb.conf \
&& sed -i '0,/\# log-enabled = true/{s/\# log-enabled = true/log-enabled = false/}' /etc/influxdb/influxdb.conf
# Add pgwatch2 sources
ADD pgwatch2 /pgwatch2
ADD webpy /pgwatch2/webpy
# Go installation [https://golang.org/dl/]
# Grafana config customizations, Web UI requirements, compilation of the Go gatherer
RUN wget -q -O /tmp/go.tar.gz https://storage.googleapis.com/golang/go1.10.3.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
&& export PATH=$PATH:/usr/local/go/bin \
&& cp /pgwatch2/bootstrap/grafana_custom_config.ini /etc/grafana/grafana.ini \
&& pip3 install -r /pgwatch2/webpy/requirements.txt \
&& pip install psutil \
&& cd /pgwatch2 && bash build_gatherer.sh \
&& rm /tmp/go.tar.gz \
&& rm -rf /usr/local/go /root/go \
&& grafana-cli plugins install savantly-heatmap-panel
ADD grafana_dashboards /pgwatch2/grafana_dashboards
# For showing all component versions via :8080/versions. Assuming project is cloned from Github here
COPY .git/refs/heads/master /pgwatch2/build_git_version.txt
# Set up supervisord [https://docs.docker.com/engine/admin/using_supervisord/]
COPY supervisord.conf /etc/supervisor/supervisord.conf
# Postgres (ver 9.5) config tuning
# NB! When security is a concern one should definitely alter "pgwatch2" password in change_pw.sql and maybe modify pg_hba.conf accordingly
COPY postgresql.conf /etc/postgresql/9.5/main/pgwatch_postgresql.conf
COPY pg_hba.conf /etc/postgresql/9.5/main/pg_hba.conf
COPY docker-launcher.sh postgresql.conf pg_hba.conf /pgwatch2/
# Admin UI for configuring servers to be monitored
EXPOSE 8080
# Gatherer healthcheck port / metric statistics (JSON)
EXPOSE 8081
# Postgres DB holding the pgwatch2 config DB
EXPOSE 5432
# Grafana UI
EXPOSE 3000
# InfluxDB API
EXPOSE 8086
# InfluxDB backup port
EXPOSE 8088
### Volumes for easier updating to newer to newer pgwatch2 containers
### NB! Backwards compatibility is not 100% guaranteed (e.g. InfluxDB has changed index storage format) so a backup
### using traditional means is still recommended before updating - see "Updating to a newer Docker version" from README
VOLUME /pgwatch2/persistent-config
VOLUME /var/lib/postgresql
VOLUME /var/lib/influxdb
VOLUME /var/lib/grafana
CMD ["/pgwatch2/docker-launcher.sh"]