File tree 7 files changed +99
-11
lines changed 7 files changed +99
-11
lines changed Original file line number Diff line number Diff line change @@ -39,17 +39,23 @@ before_install:
39
39
40
40
install :
41
41
- pip install -e .
42
- # TODO: removed when openwisp-controller 0.8.0 is released
43
- - pip install -U https://github.com/openwisp/openwisp-controller/tarball/master
44
- # TODO: removed when openwisp-users 0.3.0 is released
45
- - pip install -U https://github.com/openwisp/openwisp-users/tarball/master
46
- # TODO: remove when openwisp-notifications 0.1 is released
47
- - pip install -U https://github.com/openwisp/openwisp-notifications/tarball/master
42
+ - sh install-dev.sh
48
43
49
44
script :
50
45
- ./run-qa-checks
51
46
- SAMPLE_APP=1 coverage run --source=openwisp_monitoring runtests.py
52
47
- coverage run -a --source=openwisp_monitoring runtests.py
53
48
49
+ jobs :
50
+ include :
51
+ - stage : Deploy
52
+ before_install : skip
53
+ install : skip
54
+ if : type = push AND branch = master
55
+ script :
56
+ - echo "$DOCKER_TOKEN" | docker login --username $DOCKER_USERNAME --password-stdin
57
+ - docker build . -t openwisp/openwisp-monitoring:develop
58
+ - docker push openwisp/openwisp-monitoring:develop
59
+
54
60
after_success :
55
61
coveralls
Original file line number Diff line number Diff line change
1
+ FROM python:3.7.5-slim-buster
2
+
3
+ RUN apt update && \
4
+ apt install --yes zlib1g-dev libjpeg-dev gdal-bin libproj-dev \
5
+ libgeos-dev libspatialite-dev libsqlite3-mod-spatialite \
6
+ sqlite3 libsqlite3-dev openssl libssl-dev fping && \
7
+ rm -rf /var/lib/apt/lists/* /root/.cache/pip/* /tmp/*
8
+
9
+ COPY install-dev.sh requirements-test.txt requirements.txt /opt/openwisp/
10
+ RUN pip install -r /opt/openwisp/requirements.txt && \
11
+ pip install -r /opt/openwisp/requirements-test.txt && \
12
+ sh /opt/openwisp/install-dev.sh && \
13
+ rm -rf /var/lib/apt/lists/* /root/.cache/pip/* /tmp/*
14
+
15
+ ADD . /opt/openwisp
16
+ RUN pip install -U /opt/openwisp && \
17
+ rm -rf /var/lib/apt/lists/* /root/.cache/pip/* /tmp/*
18
+ WORKDIR /opt/openwisp/tests/
19
+ ENV NAME=openwisp-monitoring \
20
+ PYTHONBUFFERED=1 \
21
+ INFLUXDB_HOST=influxdb \
22
+ REDIS_HOST=redis
23
+ CMD ["sh" , "docker-entrypoint.sh" ]
24
+ EXPOSE 8000
Original file line number Diff line number Diff line change @@ -614,6 +614,12 @@ Install your forked repo:
614
614
cd openwisp-monitoring/
615
615
python setup.py develop
616
616
617
+ Install development dependencies:
618
+
619
+ .. code-block :: shell
620
+
621
+ ./install-dev.sh
622
+
617
623
Install test requirements:
618
624
619
625
.. code-block :: shell
@@ -624,7 +630,7 @@ Start Redis and InfluxDB using docker-compose:
624
630
625
631
.. code-block :: shell
626
632
627
- docker-compose up -d
633
+ docker-compose up -d redis influxdb
628
634
629
635
Create the Django database:
630
636
@@ -670,6 +676,15 @@ which are simple django apps that extend ``openwisp-monitoring`` with
670
676
the sole purpose of testing its extensibility, for more information regarding
671
677
this concept, read the following section.
672
678
679
+ Install and run on docker
680
+ -------------------------
681
+
682
+ .. code-block :: shell
683
+
684
+ # ``--build`` parameter is useful when you want to
685
+ # rebuild the openwisp-monitoring image with your changes.
686
+ docker-compose up --build
687
+
673
688
Extending openwisp-monitoring
674
689
-----------------------------
675
690
Original file line number Diff line number Diff line change 1
1
version : " 3"
2
2
3
3
services :
4
+ monitoring :
5
+ image : openwisp/openwisp-monitoring:develop
6
+ build :
7
+ context : .
8
+ dockerfile : Dockerfile
9
+ ports :
10
+ - " 8000:8000"
11
+ depends_on :
12
+ - influxdb
13
+ - redis
14
+
4
15
influxdb :
5
16
image : influxdb:1.8-alpine
6
17
volumes :
@@ -19,4 +30,4 @@ services:
19
30
entrypoint : redis-server --appendonly yes
20
31
21
32
volumes :
22
- influxdb-data :
33
+ influxdb-data : {}
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # TODO: removed when openwisp-controller 0.8.0 is released
4
+ pip install -U https://github.com/openwisp/openwisp-controller/tarball/master
5
+ # TODO: removed when openwisp-users 0.3.0 is released
6
+ pip install -U https://github.com/openwisp/openwisp-users/tarball/master
7
+ # TODO: remove when openwisp-notifications 0.1 is released
8
+ pip install -U https://github.com/openwisp/openwisp-notifications/tarball/master
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ create_superuser () {
4
+ local username=" $1 "
5
+ local email=" $2 "
6
+ local password=" $3 "
7
+ cat << EOF | python manage.py shell
8
+ from django.contrib.auth import get_user_model
9
+
10
+ User = get_user_model()
11
+
12
+ if not User.objects.filter(username="$username ").exists():
13
+ User.objects.create_superuser("$username ", "$email ", "$password ")
14
+ else:
15
+ print('User "{}" exists already, not created'.format("$username "))
16
+ EOF
17
+ }
18
+
19
+ python manage.py migrate --no-input
20
+ create_superuser admin
[email protected] admin
21
+ celery -A openwisp2 worker -l info &
22
+ celery -A openwisp2 beat -l info &
23
+ python manage.py runserver 0.0.0.0:8000
Original file line number Diff line number Diff line change 21
21
'USER' : 'openwisp' ,
22
22
'PASSWORD' : 'openwisp' ,
23
23
'NAME' : 'openwisp2' ,
24
- 'HOST' : ' localhost' ,
24
+ 'HOST' : os . getenv ( 'INFLUXDB_HOST' , ' localhost') ,
25
25
'PORT' : '8086' ,
26
26
}
27
27
144
144
145
145
OPENWISP_MONITORING_MANAGEMENT_IP_ONLY = False
146
146
147
+ redis_host = os .getenv ('REDIS_HOST' , 'localhost' )
147
148
CACHES = {
148
149
'default' : {
149
150
'BACKEND' : 'django_redis.cache.RedisCache' ,
150
- 'LOCATION' : 'redis://localhost /0' ,
151
+ 'LOCATION' : f 'redis://{ redis_host } /0' ,
151
152
'OPTIONS' : {'CLIENT_CLASS' : 'django_redis.client.DefaultClient' ,},
152
153
}
153
154
}
156
157
SESSION_CACHE_ALIAS = 'default'
157
158
158
159
if not TESTING :
159
- CELERY_BROKER_URL = 'redis://localhost /1'
160
+ CELERY_BROKER_URL = f 'redis://{ redis_host } /1'
160
161
else :
161
162
CELERY_TASK_ALWAYS_EAGER = True
162
163
CELERY_TASK_EAGER_PROPAGATES = True
You can’t perform that action at this time.
0 commit comments