Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

very weird bug with containers inside virtual box #60

Open
rande opened this issue Nov 28, 2018 · 0 comments
Open

very weird bug with containers inside virtual box #60

rande opened this issue Nov 28, 2018 · 0 comments

Comments

@rande
Copy link

rande commented Nov 28, 2018

Hello,

I have a working setup on Docker for Mac + Modd in a docker-compose file to restart 2 services: api and ssr. modd is working fine.

Now, I am testing the same code inside a VirtualBox VM with docker, modd only "see" changes for one service (randomly, or there is a race condition somewhere) so it is either api or ssr which get the notification.

To make it works, I switch to inotifywait, and both containers "see" the notification. So, there is a bug with modd (I have tested version 0.5 and 0.7 of modd) but I cannot understand why.

Subject: [PATCH] feat(dx): experiment vagrant box

---
 Makefile                       |  4 +-
 infra/docker-compose.local.yml | 73 +++++++---------------------------
 infra/local/node/Dockerfile    |  5 +++
 infra/local/node/watch.sh      | 22 ++++++++++
 modd_api.conf                  |  4 --
 modd_ssr.conf                  |  4 --
 6 files changed, 43 insertions(+), 69 deletions(-)
 create mode 100644 infra/local/node/Dockerfile
 create mode 100755 infra/local/node/watch.sh
 delete mode 100644 modd_api.conf
 delete mode 100644 modd_ssr.conf

diff --git a/Makefile b/Makefile
index d2c40a6..3ef509b 100644
diff --git a/infra/docker-compose.local.yml b/infra/docker-compose.local.yml
index 98ffef5..8ecf650 100644
--- a/infra/docker-compose.local.yml
+++ b/infra/docker-compose.local.yml
@@ -19,86 +19,41 @@ services:
             - watch
 
     api:
-        image: ekino/docker-buildbox:node10.4-2018.06.14
+        build: local/node
         ports:
             - "0.0.0.0:8181:8181"
         volumes:
-            - ../:/code:cached
+            - ../:/code
         working_dir: /code
-        command: modd -f modd_api.conf
+        command: watch.sh /code/src/api "node src/api/server.js"
 
     ssr:
-        image: ekino/docker-buildbox:node10.4-2018.06.14
+        build: local/node
         ports:
             - "0.0.0.0:8080:8080"
+        volumes:
+            - ../:/code
+        working_dir: /code
+        command: watch.sh /code/src/ssr "node src/ssr/server.js"
         environment:
             - API_URL=http://api:8181
             - NODE_ENV=development
-        volumes:
-            - ../:/code:cached
-        working_dir: /code
-        command: modd -f modd_ssr.conf
+
         links:
             - api
 
diff --git a/infra/local/node/Dockerfile b/infra/local/node/Dockerfile
new file mode 100644
index 0000000..0a9e803
--- /dev/null
+++ b/infra/local/node/Dockerfile
@@ -0,0 +1,5 @@
+FROM ekino/docker-buildbox:node10.4-2018.06.14
+
+RUN apt-get update && apt-get install -yy inotify-tools
+
+ADD watch.sh /usr/bin/watch.sh
\ No newline at end of file
diff --git a/infra/local/node/watch.sh b/infra/local/node/watch.sh
new file mode 100755
index 0000000..5446232
--- /dev/null
+++ b/infra/local/node/watch.sh
@@ -0,0 +1,22 @@
+#!/bin/sh 
+
+sigint_handler()
+{
+  kill $PID
+  exit
+}
+
+WATCH_PATH=$1
+START_PROCESS=$2
+
+echo "Watch path: ${WATCH_PATH}"
+echo "Start process: ${START_PROCESS}"
+
+trap sigint_handler SIGINT
+
+while true; do
+  $START_PROCESS &
+  PID=$!
+  inotifywait -e modify -e move -e create -e delete -e attrib -r $WATCH_PATH
+  kill $PID
+done
\ No newline at end of file
diff --git a/modd_api.conf b/modd_api.conf
deleted file mode 100644
index caa0a5e..0000000
--- a/modd_api.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-src/api/**/*.js {
-    # Server runs on port localhost:8080
-    daemon: node ./src/api/server.js
-}
\ No newline at end of file
diff --git a/modd_ssr.conf b/modd_ssr.conf
deleted file mode 100644
index 55470e4..0000000
--- a/modd_ssr.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-src/ssr/* {
-    # Server runs on port localhost:8080
-    daemon: node ./src/ssr/server.js
-}
\ No newline at end of file
-- 
2.18.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant