This commit is contained in:
Mike 2024-12-26 08:15:00 -05:00
parent 1d28883841
commit e07590d6e5
3 changed files with 18 additions and 4 deletions

View file

@ -1,3 +1,2 @@
node_modules/ node_modules/
Dockerfile Dockerfile
package-lock.json

View file

@ -1,15 +1,17 @@
FROM node:23-alpine FROM node:23-alpine
COPY package.json package-lock.json /app COPY package*.json /app/package*.json
WORKDIR /app WORKDIR /app
RUN npm install . RUN npm install .
COPY --chown nobody:nobody ./src /app COPY --chown=nobody:nobody ./src /app/src
EXPOSE 3000 EXPOSE 3000
USER nobody
CMD ["node", "src/app.js"] CMD ["node", "src/app.js"]

View file

@ -18,6 +18,19 @@ app.use(express.urlencoded({ extended: true }));
app.use("/", indexRouter); app.use("/", indexRouter);
//app.use("/new", msgRouter); //app.use("/new", msgRouter);
app.listen(port, () => { const server = app.listen(port, () => {
console.log(`Webserver running on ${port}.`); console.log(`Webserver running on ${port}.`);
}); });
// Shutdown Logic
const gracefulShutdownHandler = (signal) => {
console.log(`Caught ${signal}, gracefully shutting down`);
server.close(() => {
console.log(`Shutting down server`);
process.exit();
});
};
process.on("SIGINT", gracefulShutdownHandler);
process.on("SIGTERM", gracefulShutdownHandler);