Browse Source

Move node modules before running setup

Girish Ramakrishnan 7 years ago
parent
commit
efc0a81832
3 changed files with 13 additions and 10 deletions
  1. 1 1
      Dockerfile
  2. 8 8
      start.sh
  3. 4 1
      test/test.js

+ 1 - 1
Dockerfile

@@ -8,6 +8,7 @@ ENV PATH /usr/local/node-6.9.5/bin:$PATH
 
 RUN curl -L https://github.com/NodeBB/NodeBB/archive/v1.7.0.tar.gz | tar -xz --strip-components 1 -f -
 ADD config.json.template /app/code
+RUN cp /app/code/package.default.json /app/code/package.json
 RUN npm install --production
 RUN npm install nodebb-plugin-emailer-local
 
@@ -16,7 +17,6 @@ RUN mv /app/code/node_modules /app/code/node_modules_copy && ln -s /run/nodebb/n
 	rm -rf /app/code/logs && ln -sf /run/nodebb/logs /app/code/logs && \
 	ln -s /run/nodebb/config.json /app/code/config.json && \
 	ln -s /run/nodebb/build /app/code/build && \
-	# required for npm install to work at runtime (for nodebb plugins)
 	rm -rf /home/cloudron/.npm && ln -s /run/nodebb/npm /home/cloudron/.npm
 
 ADD start.sh /app/code/start.sh

+ 8 - 8
start.sh

@@ -7,6 +7,13 @@ mongo_cli="mongo ${MONGODB_HOST}:${MONGODB_PORT}/${MONGODB_DATABASE} -u ${MONGOD
 echo "=> Creating directories"
 mkdir -p /app/data/public/uploads /run/nodebb/logs /run/nodebb/public /run/nodebb/node_modules /run/nodebb/npm /run/nodebb/build
 
+export NODE_ENV=production
+export NODE_PATH=/app/code/node_modules
+
+# Some plugins write stuff into node_modules. Not nice :/
+echo "=> Moving node_modules"
+cp -rf /app/code/node_modules_copy/* /run/nodebb/node_modules
+
 if [[ -z "$(ls -A /run/nodebb/public)" ]]; then
     echo "=> Copying public files"
 
@@ -21,15 +28,8 @@ if [[ -z "$(ls -A /run/nodebb/public)" ]]; then
     ln -s /app/code/src /run/nodebb/src
 fi
 
-# Some plugins write stuff into node_modules. Not nice :/
-echo "=> Moving node_modules"
-cp -rf /app/code/node_modules_copy/* /run/nodebb/node_modules
-
 chown -R cloudron:cloudron /app/data /run/nodebb
 
-export NODE_ENV=production
-export NODE_PATH=/app/code/node_modules
-
 if [[ ! -f /app/data/.setup_done ]]; then
     echo "=> Running initial setup"
     setup="{
@@ -47,7 +47,7 @@ if [[ ! -f /app/data/.setup_done ]]; then
     }"
 
     # this will create a config.json
-    /usr/local/bin/gosu cloudron:cloudron node /app/code/app --setup "${setup}"  --series
+    cd /app/code && /usr/local/bin/gosu cloudron:cloudron node /app/code/app --setup "${setup}"  --series
     touch /app/data/.setup_done
 fi
 

+ 4 - 1
test/test.js

@@ -112,7 +112,10 @@ describe('Application life cycle test', function () {
         }).then(function () {
             return browser.findElement(by.xpath('//li[@id="nodebb-plugin-beep"]//button[@data-action="toggleActive"]')).click(); // activate the plugin
         }).then(function () {
-            return browser.wait(until.elementLocated(by.xpath('//button[text()="Confirm"]')), TEST_TIMEOUT);
+           return browser.wait(until.elementLocated(by.xpath('//button[text()="Confirm"]')), TEST_TIMEOUT);
+        }).then(function () {
+            var button = browser.findElement(by.xpath('//button[text()="Confirm"]'));
+            return browser.executeScript('arguments[0].scrollIntoView(false)', button);
         }).then(function () {
             return browser.findElement(by.xpath('//button[text()="Confirm"]')).click();
         }).then(function () {