Development Override Compose File
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Fri, 5 Oct 2018 23:05:20 +0000 (16:05 -0700)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Tue, 9 Oct 2018 00:03:33 +0000 (17:03 -0700)
Now that images are built and hosted for the dashboard and worker
container the compose file can reference upstream images instead of
ones locally built.

A second compose file is added which overrides compose configuration so
that images are built locally.

Initial commands for running the container are moved into 'init.sh'
which gets copied into the image, since the current images cannot be ran
by themselves as they require the command listed in the compose file.

The compose version bumped from 2 to 3 as there are no version 2
specific features being used that need to be modified.

Change-Id: I23813a859a676ba009cba8f5a62b7153da006eef
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Makefile
docker-compose.override-dev.yml [new file with mode: 0644]
docker-compose.yml
readme.txt
requirements.txt [moved from web/requirements.txt with 100% similarity]
src/static/bower.json
web/Dockerfile
web/init.sh [new file with mode: 0755]
worker/Dockerfile
worker/init.sh [new file with mode: 0755]
worker/requirements.txt [deleted file]

index 9070917..e5f4fb2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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 (file)
index 0000000..e1e1632
--- /dev/null
@@ -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
index 4e57ff3..19e9afd 100644 (file)
@@ -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
index 2a25912..96ece92 100644 (file)
@@ -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'
similarity index 100%
rename from web/requirements.txt
rename to requirements.txt
index f473747..9ae744a 100644 (file)
@@ -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"
   }
 }
index 228b0b0..a153192 100644 (file)
@@ -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 (executable)
index 0000000..736acc1
--- /dev/null
@@ -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
index c1e8aff..cd0f797 100644 (file)
@@ -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 (executable)
index 0000000..ecec2a1
--- /dev/null
@@ -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 (file)
index 19365bc..0000000
+++ /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