Compare commits

..

2 Commits

Author SHA1 Message Date
aa5ef10e85 Add .env so builds can take into account PUBLIC_URL and BASE_PATH -- need to switch those to be variables?
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
2023-01-20 16:19:18 -08:00
ccdfd2513f Fixed lots of issues
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
2023-01-20 16:08:32 -08:00
4 changed files with 44 additions and 3 deletions

View File

@ -5,6 +5,7 @@
!*.js
!*.sh
!*.md
!.env
!config
config/local.json
!client

View File

@ -29,14 +29,21 @@ 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
COPY /.env /website/
RUN npm run build
# Polymer frontend app built using bower
WORKDIR /website/frontend
COPY /frontend /website/frontend
RUN npx -y bower -y install
# 'identities' frontend built using react
WORKDIR /website/client
COPY /client/package.json /website/client/
RUN npm install
@ -44,6 +51,7 @@ COPY /client/tsconfig.json /website/client/
COPY /client/*.js /website/client/
COPY /client/public /website/client/public
COPY /client/src /website/client/src
COPY /client/.env /website/client/
RUN npm run build
#
@ -81,6 +89,7 @@ WORKDIR /website/server
COPY /server/package.json /website/server/
RUN npm install
COPY /.env /website/
COPY /config /website/config
COPY /server/*.js /website/server/
COPY /server/db /website/server/db
@ -96,7 +105,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

View File

@ -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

View File

@ -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,