Skip to content

Commit 76cc466

Browse files
ElfoLiNkdpsoft
authored andcommitted
Alpine and Dependencies Upgrade (#115)
1 parent d3ab878 commit 76cc466

File tree

5 files changed

+65
-58
lines changed

5 files changed

+65
-58
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ logs
22
*.sw[op]
33
data/
44
log/
5+
.idea/

Dockerfile

+58-53
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
1-
FROM ubuntu:14.04
1+
FROM alpine
22

33
# ---------------- #
44
# Installation #
55
# ---------------- #
66

7-
ENV DEBIAN_FRONTEND noninteractive
8-
97
# Install all prerequisites
10-
RUN apt-get -y update &&\
11-
apt-get -y install software-properties-common python-django-tagging python-simplejson \
12-
python-memcache python-ldap python-cairo python-pysqlite2 python-support python-pip \
13-
gunicorn supervisor nginx-light git wget curl openjdk-7-jre build-essential python-dev libffi-dev
14-
15-
RUN pip install Twisted==13.2.0
16-
RUN pip install pytz
17-
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
18-
RUN apt-get install -y nodejs
19-
RUN npm install -g wizzy
20-
21-
# Checkout the stable branches of Graphite, Carbon and Whisper and install from there
22-
RUN mkdir /src
23-
RUN git clone https://github.com/graphite-project/whisper.git /src/whisper &&\
24-
cd /src/whisper &&\
25-
git checkout 1.0.x &&\
8+
RUN apk add --update --no-cache nginx nodejs nodejs-npm git curl wget gcc ca-certificates \
9+
python-dev py-pip musl-dev libffi-dev cairo supervisor bash \
10+
py-pyldap py-rrd &&\
11+
wget -q -O /etc/apk/keys/sgerrand.rsa.pub \
12+
https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub &&\
13+
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.26-r0/glibc-2.26-r0.apk &&\
14+
apk add --no-cache glibc-2.26-r0.apk &&\
15+
rm glibc-2.26-r0.apk &&\
16+
adduser -D -u 1000 -g 'www' www &&\
17+
pip install -U pip pytz gunicorn six --no-cache-dir &&\
18+
npm install -g wizzy &&\
19+
npm cache clean --force
20+
21+
# Checkout the master branches of Graphite, Carbon and Whisper and install from there
22+
RUN mkdir /src &&\
23+
git clone --depth=1 --branch master https://github.com/graphite-project/whisper.git /src/whisper &&\
24+
cd /src/whisper &&\
25+
pip install . --no-cache-dir &&\
2626
python setup.py install
2727

28-
RUN git clone https://github.com/graphite-project/carbon.git /src/carbon &&\
29-
cd /src/carbon &&\
30-
git checkout 1.0.x &&\
28+
RUN git clone --depth=1 --branch master https://github.com/graphite-project/carbon.git /src/carbon &&\
29+
cd /src/carbon &&\
30+
pip install . --no-cache-dir &&\
3131
python setup.py install
3232

33-
34-
RUN git clone https://github.com/graphite-project/graphite-web.git /src/graphite-web &&\
35-
cd /src/graphite-web &&\
36-
git checkout 1.0.x &&\
37-
python setup.py install &&\
38-
pip install -r requirements.txt &&\
33+
RUN git clone --depth=1 --branch master https://github.com/graphite-project/graphite-web.git /src/graphite-web &&\
34+
cd /src/graphite-web &&\
35+
pip install . --no-cache-dir &&\
36+
python setup.py install &&\
37+
pip install -r requirements.txt --no-cache-dir &&\
3938
python check-dependencies.py
4039

4140
# Install StatsD
42-
RUN git clone https://github.com/etsy/statsd.git /src/statsd &&\
43-
cd /src/statsd &&\
44-
git checkout v0.8.0
45-
41+
RUN git clone --depth=1 --branch master https://github.com/etsy/statsd.git /src/statsd
4642

4743
# Install Grafana
48-
RUN mkdir /src/grafana &&\
49-
mkdir /opt/grafana &&\
50-
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.4.3.linux-x64.tar.gz -O /src/grafana.tar.gz &&\
51-
tar -xzf /src/grafana.tar.gz -C /opt/grafana --strip-components=1 &&\
44+
RUN mkdir /src/grafana &&\
45+
mkdir /opt/grafana &&\
46+
curl https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.1.linux-x64.tar.gz \
47+
-o /src/grafana.tar.gz &&\
48+
tar -xzf /src/grafana.tar.gz -C /opt/grafana --strip-components=1 &&\
5249
rm /src/grafana.tar.gz
5350

5451

52+
# Cleanup Compile Dependencies
53+
RUN apk del --no-cache git curl wget gcc python-dev musl-dev libffi-dev
54+
55+
5556
# ----------------- #
5657
# Configuration #
5758
# ----------------- #
@@ -65,30 +66,33 @@ ADD ./graphite/local_settings.py /opt/graphite/webapp/graphite/local_setting
6566
ADD ./graphite/carbon.conf /opt/graphite/conf/carbon.conf
6667
ADD ./graphite/storage-schemas.conf /opt/graphite/conf/storage-schemas.conf
6768
ADD ./graphite/storage-aggregation.conf /opt/graphite/conf/storage-aggregation.conf
68-
RUN mkdir -p /opt/graphite/storage/whisper
69-
RUN touch /opt/graphite/storage/graphite.db /opt/graphite/storage/index
70-
RUN chown -R www-data /opt/graphite/storage
71-
RUN chmod 0775 /opt/graphite/storage /opt/graphite/storage/whisper
72-
RUN chmod 0664 /opt/graphite/storage/graphite.db
73-
RUN cp /src/graphite-web/webapp/manage.py /opt/graphite/webapp
74-
RUN cd /opt/graphite/webapp/ && python manage.py migrate --run-syncdb --noinput
69+
RUN mkdir -p /opt/graphite/storage/whisper &&\
70+
touch /opt/graphite/storage/graphite.db /opt/graphite/storage/index &&\
71+
chown -R www /opt/graphite/storage &&\
72+
chmod 0775 /opt/graphite/storage /opt/graphite/storage/whisper &&\
73+
chmod 0664 /opt/graphite/storage/graphite.db &&\
74+
cp /src/graphite-web/webapp/manage.py /opt/graphite/webapp &&\
75+
cd /opt/graphite/webapp/ && python manage.py migrate --run-syncdb --noinput
7576

7677
# Configure Grafana and wizzy
7778
ADD ./grafana/custom.ini /opt/grafana/conf/custom.ini
78-
RUN cd /src && wizzy init &&\
79-
extract() { cat /opt/grafana/conf/custom.ini | grep $1 | awk '{print $NF}'; } &&\
80-
wizzy set grafana url $(extract ";protocol")://$(extract ";domain"):$(extract ";http_port") &&\
81-
wizzy set grafana username $(extract ";admin_user") &&\
82-
wizzy set grafana password $(extract ";admin_password")
79+
RUN cd /src &&\
80+
wizzy init &&\
81+
extract() { cat /opt/grafana/conf/custom.ini | grep $1 | awk '{print $NF}'; } &&\
82+
wizzy set grafana url $(extract ";protocol")://$(extract ";domain"):$(extract ";http_port") &&\
83+
wizzy set grafana username $(extract ";admin_user") &&\
84+
wizzy set grafana password $(extract ";admin_password")
85+
8386
# Add the default datasource and dashboards
84-
RUN mkdir /src/datasources
85-
ADD ./grafana/datasources/* /src/datasources
86-
RUN mkdir /src/dashboards
87+
RUN mkdir /src/datasources &&\
88+
mkdir /src/dashboards
89+
ADD ./grafana/datasources/* /src/datasources
8790
ADD ./grafana/dashboards/* /src/dashboards/
8891
ADD ./grafana/export-datasources-and-dashboards.sh /src/
8992

9093
# Configure nginx and supervisord
9194
ADD ./nginx/nginx.conf /etc/nginx/nginx.conf
95+
RUN mkdir /var/log/supervisor
9296
ADD ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
9397

9498

@@ -108,11 +112,12 @@ EXPOSE 8126
108112
# Graphite web port
109113
EXPOSE 81
110114

115+
# Graphite Carbon port
116+
EXPOSE 2003
111117

112118

113119
# -------- #
114120
# Run! #
115121
# -------- #
116122

117-
CMD ["/usr/bin/supervisord"]
118-
123+
CMD ["/usr/bin/supervisord", "--nodaemon", "--configuration", "/etc/supervisor/conf.d/supervisord.conf"]

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ services:
1414
- ./data/whisper:/opt/graphite/storage/whisper
1515
- ./data/grafana:/opt/grafana/data
1616
- ./log/graphite:/opt/graphite/storage/log
17+
- ./log/supervisor:/var/log/supervisor

nginx/nginx.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
daemon off;
2-
user www-data;
2+
user www;
33
worker_processes 1;
44
pid /var/run/nginx.pid;
55

supervisord.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ stderr_logfile = /var/log/supervisor/%(program_name)s.log
99
autorestart = true
1010

1111
[program:carbon-cache]
12-
;user = www-data
12+
;user = www
1313
command = /opt/graphite/bin/carbon-cache.py --pidfile /var/run/carbon-cache-a.pid --debug start
1414
stdout_logfile = /var/log/supervisor/%(program_name)s.log
1515
stderr_logfile = /var/log/supervisor/%(program_name)s.log
1616
autorestart = true
1717

1818
[program:grafana-webapp]
19-
;user = www-data
19+
;user = www
2020
directory = /opt/grafana/
2121
command = /opt/grafana/bin/grafana-server
2222
stdout_logfile = /var/log/supervisor/%(program_name)s.log
2323
stderr_logfile = /var/log/supervisor/%(program_name)s.log
2424
autorestart = true
2525

2626
[program:graphite-webapp]
27-
;user = www-data
27+
;user = www
2828
directory = /opt/graphite/webapp
2929
environment = PYTHONPATH='/opt/graphite/webapp'
3030
command = /usr/bin/gunicorn -b127.0.0.1:8000 -w 4 graphite.wsgi:application
@@ -33,7 +33,7 @@ stderr_logfile = /var/log/supervisor/%(program_name)s.log
3333
autorestart = true
3434

3535
[program:statsd]
36-
;user = www-data
36+
;user = www
3737
command = /usr/bin/node /src/statsd/stats.js /src/statsd/config.js
3838
stdout_logfile = /var/log/supervisor/%(program_name)s.log
3939
stderr_logfile = /var/log/supervisor/%(program_name)s.log

0 commit comments

Comments
 (0)