Skip to content

Commit

Permalink
[docker] Updated docker setup to work with the new version
Browse files Browse the repository at this point in the history
  • Loading branch information
atb00ker committed Jun 17, 2019
1 parent 51d4cbe commit a9def57
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 22 deletions.
44 changes: 27 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
FROM python:3-onbuild
FROM python:3.7-alpine

WORKDIR .
RUN apt-get update && apt-get install -y \
openssl \
sqlite3 \
libsqlite3-dev \
libssl-dev \
gdal-bin \
libproj-dev \
libgeos-dev \
libspatialite-dev
RUN pip3 install -U pip setuptools wheel
RUN pip3 install -U .
RUN echo "openwisp-controller installed"
WORKDIR tests/
CMD ["./docker-entrypoint.sh"]
WORKDIR /opt/openwisp/
CMD ["sh", "docker-entrypoint.sh"]
EXPOSE 8000
ENV NAME=openwisp-controller \
PYTHONBUFFERED=1

ENV NAME openwisp-controller
RUN apk add --no-cache \
--update zlib-dev jpeg-dev libffi-dev gettext gcc openssl tzdata && \
apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
--update geos-dev gdal-dev libspatialite && \
apk add --no-cache \
--update \
--virtual .build-deps postgresql-dev git build-base linux-headers openssl-dev

RUN pip install django-netjsonconfig openwisp-utils scp celery asgi_redis \
django-loci paramiko openwisp-users cryptography==2.3.1 \
djangorestframework-gis redis service_identity django-redis

ADD . /opt/openwisp

RUN pip install -U . && \
pip install https://github.com/openwisp/openwisp-users/tarball/master && \
pip install https://github.com/openwisp/django-netjsonconfig/tarball/master && \
pip install https://github.com/openwisp/django-x509/tarball/master && \
pip install https://github.com/openwisp/openwisp-utils/tarball/master

WORKDIR /opt/openwisp/tests/
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ Build from the Dockerfile:

.. code-block:: shell
sudo docker build -t openwisp/controller .
docker-compose build
Run the docker container:

.. code-block:: shell
sudo docker run -it -p 8000:8000 openwisp/controller
docker-compose up
Troubleshooting Steps
---------------------
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3"

services:
controller:
image: openwisp/controller-development:latest
build:
context: .
ports:
- 8000:8000
depends_on:
- redis

redis:
image: redis:alpine
23 changes: 20 additions & 3 deletions tests/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#!/bin/bash

python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py runserver 0.0.0.0:8000
create_superuser () {
local username="$1"
local email="$2"
local password="$3"
cat <<EOF | python manage.py shell
from django.contrib.auth import get_user_model
User = get_user_model()
if not User.objects.filter(username="$username").exists():
User.objects.create_superuser("$username", "$email", "$password")
else:
print('User "{}" exists already, not created'.format("$username"))
EOF
}

python manage.py migrate --no-input
create_superuser admin admin@example.com admin
celery -A openwisp2 worker -l info & \
python manage.py runserver 0.0.0.0:8000

0 comments on commit a9def57

Please sign in to comment.