devel: use mounts for development 78/69378/1
authorJeremy Plsek <jeremyplsek@gmail.com>
Tue, 17 Dec 2019 20:13:00 +0000 (15:13 -0500)
committerJeremy Plsek <jeremyplsek@gmail.com>
Tue, 17 Dec 2019 20:13:00 +0000 (15:13 -0500)
This removes the need to rebuild the containers every time for simple
changes during development.
This does not include python dependencies since those are installed
globally in the container. (I would have done the same for JS
dependencies, but it's used in the static files.)

Removed the background flag for running in dev mode when using make.
It's easier to kill the servers (^C) and view logs of the server without
needing to call separate commands later.

Nginx is disabled in dev mode since the server and static files are
handled by Django instead.

Update readme to reflect upon changes made.

Signed-off-by: Jeremy Plsek <jeremyplsek@gmail.com>
Change-Id: I7888ca89021fca313e1043a7f94b5e1b7e12498c

Makefile
docker-compose.override-dev.yml
readme.txt
web/Dockerfile

index 0342381..eccb215 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ 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
+       docker-compose -f docker-compose.yml -f docker-compose.override-dev.yml up
 
 dev-start:
        docker-compose -f docker-compose.yml -f docker-compose.override-dev.yml start
index b9de639..c6ee3b8 100644 (file)
@@ -9,11 +9,24 @@
 ##############################################################################
 version: '3'
 services:
+    nginx:
+        command: echo "Nginx is disabled in dev mode."
+        restart: "no"
+
     web:
         image: opnfv/laas-dashboard:dev
         build:
             context: .
             dockerfile: web/Dockerfile
+        command: >
+            sh -c "cd static && bower install --allow-root && cd .. &&
+                   ./manage.py migrate &&
+                   ./manage.py runserver 0:8000"
+        volumes:
+            - ./src:/laas_dashboard
+        ports:
+            - "8000:8000"
+
     worker:
         image: opnfv/laas-celery:dev
         build:
index fad9e71..6f48812 100644 (file)
@@ -19,7 +19,10 @@ Deployment:
 - complete the config.env.sample file and save it as config.env
 - install docker, docker-compose
 - run 'make data'
-- run 'make up' to run the dashboard
+- run 'make up' to run the dashboard (or 'make dev-up' for development)
+
+Production will be running on port 80 by default.
+Development will be running on port 8000 by default.
 
 Updating:
 
index bdb9b41..fe525ca 100644 (file)
@@ -6,21 +6,20 @@
 # 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 apt-get update && apt-get install -y npm
+RUN npm install -g bower
+
 ADD requirements.txt /requirements.txt
 RUN pip install -r /requirements.txt
 
 ADD web/init.sh /init.sh
 ADD src/ /laas_dashboard/
-COPY --from=static /static/ laas_dashboard/static/
+
+ADD src/static/ laas_dashboard/static/
+RUN cd laas_dashboard/static/ && bower install --allow-root
 
 WORKDIR /laas_dashboard/
 CMD ["/init.sh"]