diff --git a/Dockerfile b/Dockerfile index 1977596..ad742b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,14 +29,20 @@ FROM base AS production RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \ git +# Not sure if the root is actually used for anything... WORKDIR /website COPY /package.json /website/ RUN npm install COPY /.babelrc /*.html /*.js /website/ COPY /src /website/src -COPY /frontend /website/frontend RUN npm run build +# Polymer frontend app built using bower +WORKDIR /website/frontend +COPY /frontend /website/frontend +RUN npx bower install + +# 'identities' frontend built using react WORKDIR /website/client COPY /client/package.json /website/client/ RUN npm install @@ -96,7 +102,7 @@ COPY /ketrface /website/ketrface FROM runtime AS website RUN echo "Building PRODUCTION" COPY /server/production.location /etc/nginx/snippets/active.location -COPY /frontend /website/frontend +COPY --from=production /frontend /website/frontend COPY --from=production /website/dist /website/dist COPY --from=production /website/*.html /website/ COPY --from=production /website/client/build /website/client/build diff --git a/entrypoint.sh b/entrypoint.sh index be4eece..e2117b9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,8 @@ #!/bin/bash +fail() { + echo "$*" >&2 + exit -1 +} if [[ "${TARGET_PORT}" != "" ]]; then sed -i -e "s,8123,${TARGET_PORT},g" /etc/nginx/sites-enabled/default @@ -26,6 +30,24 @@ if [[ -z "${DEVELOPMENT}" ]]; then { while true; do npm start ; sleep 3 ; done ; } else echo "Running in DEVELOPMENT mode." + if [[ -d /website/frontend/bower_components ]]; then + cd /website/frontend + npm install && + npx bower install || fail "Unable to install frontend" + fi + if [[ -d /website/client/node_modules ]]; then + cd /website/client + npm install || fail "Unable to install client" + fi + if [[ -d /website/node_modules ]]; then + cd /website + npm install || fail "Unable to install website" + fi + if [[ -d /website/server/node_modules ]]; then + cd /website/server + npm install || fail "Unable to install server" + fi + cd /website/server { while true; do npm start ; sleep 3 ; done ; } & cd /website/client diff --git a/server/app.js b/server/app.js index 071257b..de34088 100755 --- a/server/app.js +++ b/server/app.js @@ -91,8 +91,17 @@ app.use(function(req, res, next){ }); }); +const dbPath = { ...config.get("sessions.db") }; +let configPath = process.env.NODE_CONFIG_DIR; +if (configPath) { + configPath = configPath.replace(/config/, ''); +} else { + configPath = './' +} +dbPath = `${configPath}${dbPath}`; + app.use(session({ - store: new SQLiteStore({ db: config.get("sessions.db") }), + store: new SQLiteStore({ db: dbPath }), secret: config.get("sessions.store-secret"), cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 }, // 1 week saveUninitialized: false,