Kaynağa Gözat

Symlink node_modules in the dockerfile

Girish Ramakrishnan 8 yıl önce
ebeveyn
işleme
a6f6c7942d
2 değiştirilmiş dosya ile 6 ekleme ve 7 silme
  1. 2 0
      Dockerfile
  2. 4 7
      start.sh

+ 2 - 0
Dockerfile

@@ -8,6 +8,8 @@ WORKDIR /app/code
 RUN curl -L https://github.com/NodeBB/NodeBB/archive/v1.1.0.tar.gz | tar -xz --strip-components 1 -f -
 ADD config.json.template /app/code
 RUN npm install --production
+RUN mv /app/code/node_modules /app/code/node_modules_copy
+RUN ln -s /run/nodebb/node_modules /app/code/node_modules
 
 # these links will become valid after setup is run
 RUN mv /app/code/public /app/code/public_template && ln -sf /run/nodebb/public /app/code/public

+ 4 - 7
start.sh

@@ -3,7 +3,7 @@
 set -eu
 
 echo "Creating directories"
-mkdir -p /app/data/public/uploads /run/nodebb/logs /run/nodebb/public
+mkdir -p /app/data/public/uploads /run/nodebb/logs /run/nodebb/public /run/nodebb/node_modules
 
 if [[ -z "$(ls -A /run/nodebb/public)" ]]; then
     echo "Copying public files"
@@ -19,12 +19,9 @@ if [[ -z "$(ls -A /run/nodebb/public)" ]]; then
     ln -s /app/code/src /run/nodebb/src
 fi
 
-if [[ ! -L "/app/code/node_modules" ]]; then
-    # Some plugins write stuff into node_modules. Not nice :/
-    echo "Moving node_modules"
-    mv /app/code/node_modules /run/nodebb
-    ln -s /run/nodebb/node_modules /app/code/node_modules
-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