diff options
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | docker-compose.override-dev.yml | 25 | ||||
-rw-r--r-- | docker-compose.yml | 27 | ||||
-rw-r--r-- | readme.txt | 17 | ||||
-rw-r--r-- | requirements.txt (renamed from web/requirements.txt) | 0 | ||||
-rw-r--r-- | src/static/bower.json | 3 | ||||
-rw-r--r-- | web/Dockerfile | 29 | ||||
-rwxr-xr-x | web/init.sh | 12 | ||||
-rw-r--r-- | worker/Dockerfile | 22 | ||||
-rwxr-xr-x | worker/init.sh | 10 | ||||
-rw-r--r-- | worker/requirements.txt | 18 |
11 files changed, 123 insertions, 51 deletions
@@ -1,5 +1,14 @@ build: - docker-compose build + docker-compose -f docker-compose.yml -f docker-compose.override-dev.yml build + +dev-up: + docker-compose -f docker-compose.yml -f docker-compose.override-dev.yml up -d + +dev-start: + docker-compose -f docker-compose.yml -f docker-compose.override-dev.yml start + +dev-stop: + docker-compose -f docker-compose.yml -f docker-compose.override-dev.yml stop up: docker-compose up -d diff --git a/docker-compose.override-dev.yml b/docker-compose.override-dev.yml new file mode 100644 index 0000000..e1e1632 --- /dev/null +++ b/docker-compose.override-dev.yml @@ -0,0 +1,25 @@ +--- +############################################################################## +# Copyright (c) 2018 Trevor Bramwell and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +version: '3' +services: + web: + image: opnfv/pharos-tools-laas-dashboard:dev + build: + context: . + dockerfile: web/Dockerfile + volumes: + - ./src:/pharos_dashboard + worker: + image: opnfv/pharos-tools-laas-celery:dev + build: + context: . + dockerfile: worker/Dockerfile + volumes: + - ./src:/pharos_dashboard diff --git a/docker-compose.yml b/docker-compose.yml index 4e57ff3..19e9afd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - -version: '2' +version: '3' services: nginx: restart: always @@ -19,27 +17,23 @@ services: - "80:80" volumes: - ./config/nginx:/etc/nginx/conf.d - - /var/lib/pharos_dashboard/static:/static - - /var/lib/pharos_dashboard/media:/media + - pharos-static:/static:ro + - pharos-media:/media depends_on: - web web: + image: opnfv/pharos-tools-laas-dashboard:latest restart: always - build: ./web/ container_name: dg01 - # yamllint disable rule:line-length - command: bash -c "python manage.py migrate && python manage.py collectstatic --no-input && gunicorn pharos_dashboard.wsgi -b 0.0.0.0:8000" - # yamllint enable rule:line-length depends_on: - postgres links: - postgres env_file: config.env volumes: - - ./:/pharos_dashboard - - /var/lib/pharos_dashboard/static:/static - - /var/lib/pharos_dashboard/media:/media + - pharos-static:/pharos_dashboard/static/ + - pharos-media:/pharos_dashboard/media/ expose: - "8000" @@ -59,17 +53,14 @@ services: - "5672:5672" worker: + image: opnfv/pharos-tools-laas-celery:latest restart: always - build: ./worker/ - # yamllint disable rule:line-length - command: bash -c "celery -A pharos_dashboard worker -l info -B --schedule=~/celerybeat-schedule" - # yamllint enable rule:line-length env_file: config.env links: - postgres - rabbitmq - volumes: - - ./:/pharos_dashboard volumes: + pharos-media: + pharos-static: pharos-data: external: true @@ -9,23 +9,24 @@ The dashboard is deployed using docker-compose. -Application / database files are saved in /var/lib/pharos_dashboard/. + +Application / database files are saved in the 'pharos-data' container +which needs to be pre-built before bringing up the dashboard. Deployment: - clone the repository - complete the config.env.sample file and save it as config.env -- install docker, docker-compose and bower -- run 'bower install' in ./src/static/ to fetch javascript dependencies -- run 'make build' to build the containers +- install docker, docker-compose - run 'make data' - run 'make up' to run the dashboard Updating: +- run 'docker-compose pull' +- run 'docker-compose up -d' - make stop - git pull -- run 'bower install' if javascript dependencies changed - make build - make start @@ -34,3 +35,9 @@ If there is migrations that need user input (like renaming a field), they need t Logs / Shell access: - there is some shortcuts in the makefile + +Development: + +- Install dependencies listed in 'Deployment' +- run 'make build' +- run 'make dev-up' diff --git a/web/requirements.txt b/requirements.txt index 19365bc..19365bc 100644 --- a/web/requirements.txt +++ b/requirements.txt diff --git a/src/static/bower.json b/src/static/bower.json index f473747..9ae744a 100644 --- a/src/static/bower.json +++ b/src/static/bower.json @@ -20,5 +20,8 @@ "fullcalendar": "^2.9.0", "jquery-migrate": "^3.0.0", "startbootstrap-sb-admin-2-blackrockdigital": "^3.3.7" + }, + "resolutions": { + "font-awesome": "~4.6.3" } } diff --git a/web/Dockerfile b/web/Dockerfile index 228b0b0..a153192 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,7 +1,26 @@ +############################################################################## +# Copyright (c) 2018 Trevor Bramwell and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +FROM node as static +RUN npm install -g bower +ADD src/static/ /static +WORKDIR /static/ +RUN bower install --allow-root + FROM python:3.5 ENV PYTHONUNBUFFERED 1 -RUN mkdir /config -ADD ./requirements.txt /config/ -RUN pip install -r /config/requirements.txt -RUN mkdir -p /pharos_dashboard/src -WORKDIR /pharos_dashboard/src + +ADD requirements.txt /requirements.txt +RUN pip install -r /requirements.txt + +ADD web/init.sh /init.sh +ADD src/ /pharos_dashboard/ +COPY --from=static /static/ pharos_dashboard/static/ + +WORKDIR /pharos_dashboard/ +CMD ["/init.sh"] diff --git a/web/init.sh b/web/init.sh new file mode 100755 index 0000000..736acc1 --- /dev/null +++ b/web/init.sh @@ -0,0 +1,12 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2018 Trevor Bramwell and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +python manage.py migrate && \ +python manage.py collectstatic --no-input && \ +gunicorn pharos_dashboard.wsgi -b 0.0.0.0:8000 diff --git a/worker/Dockerfile b/worker/Dockerfile index c1e8aff..cd0f797 100644 --- a/worker/Dockerfile +++ b/worker/Dockerfile @@ -1,8 +1,22 @@ +############################################################################## +# Copyright (c) 2018 Trevor Bramwell and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## FROM python:3.5 ENV PYTHONUNBUFFERED 1 -RUN mkdir /config -ADD ./requirements.txt /config/ -RUN pip install -r /config/requirements.txt + +ADD requirements.txt /requirements.txt +RUN pip install -r /requirements.txt + +ADD worker/init.sh /init.sh +ADD src/ /pharos_dashboard/ + RUN useradd -ms /bin/bash celery USER celery -WORKDIR /pharos_dashboard/src + +WORKDIR /pharos_dashboard/ +CMD ["/init.sh"] diff --git a/worker/init.sh b/worker/init.sh new file mode 100755 index 0000000..ecec2a1 --- /dev/null +++ b/worker/init.sh @@ -0,0 +1,10 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2018 Trevor Bramwell and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +celery -A pharos_dashboard worker -l info -B --schedule=~/celerybeat-schedule diff --git a/worker/requirements.txt b/worker/requirements.txt deleted file mode 100644 index 19365bc..0000000 --- a/worker/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -celery==3.1.23 -cryptography==2.3.1 -Django==1.10 -django-bootstrap3==7.0.1 -django-crispy-forms==1.6.0 -django-filter==0.14.0 -django-registration==2.1.2 -djangorestframework==3.4.6 -gunicorn==19.6.0 -jira==1.0.7 -jsonpickle==0.9.3 -oauth2==1.9.0.post1 -oauthlib==1.1.2 -pika==0.10.0 -psycopg2==2.6.2 -PyJWT==1.4.2 -requests==2.11.0 -django-fernet-fields==0.5 |