Skip to content

Commit

Permalink
Docker: Allow file based declaration of active modules
Browse files Browse the repository at this point in the history
By default, the file is empty but a user can mount a different file into the container.

In K8s it is unsafe to first run the container and then later on activate modules. This should be done before nodebb is started.
Activating modules for each pod is safe as it is an idempotent operation.
  • Loading branch information
Brutus5000 committed Jan 19, 2023
1 parent 459bc52 commit 8e6c321
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Expand Up @@ -8,11 +8,13 @@ ARG NODE_ENV
ENV NODE_ENV $NODE_ENV

COPY --chown=node:node install/package.json /usr/src/app/package.json
COPY --chown=node:node install/launch.sh /usr/src/app/launch.sh

USER node

RUN npm install --only=prod && \
npm cache clean --force
npm cache clean --force && \
touch active_modules

COPY --chown=node:node . /usr/src/app

Expand All @@ -22,4 +24,4 @@ ENV NODE_ENV=production \

EXPOSE 4567

CMD test -n "${SETUP}" && ./nodebb setup || node ./nodebb build; node ./nodebb start
CMD ./launch.sh
18 changes: 18 additions & 0 deletions install/launch.sh
@@ -0,0 +1,18 @@
echo "# [Optional] Install "
if test -n "${SETUP}"
then
./nodebb setup
fi

echo "# Checking required modules from ./active_modules"
while read -r module; do
echo "Installing module $module"
npm install "$module"
./nodebb activate $module
done < ./active_modules

echo "# Building nodebb"
node ./nodebb build

echo "# Launching application"
./nodebb start

0 comments on commit 8e6c321

Please sign in to comment.