Skip to content

Commit

Permalink
Added pm2 to dockerfile. NO_AUTH env.
Browse files Browse the repository at this point in the history
  • Loading branch information
lllllllillllllillll committed Jun 20, 2024
1 parent 5e13288 commit 6c15c28
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ENV NODE_ENV=production
WORKDIR /app
COPY package.json /app
RUN npm install
RUN npm install pm2 -g
COPY . /app
EXPOSE 8000
CMD ["node", "server.js"]
CMD ["pm2-runtime", "server.js"]
5 changes: 3 additions & 2 deletions controllers/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ let [ports_data, volumes_data, env_data, label_data] = [[], [], [], []];
// The page
export const Dashboard = (req, res) => {

let name = req.session.user;
let name = req.session.user || 'Local';
let avatar = name.charAt(0).toUpperCase();
let role = req.session.role;
alert = req.session.alert;

res.render("dashboard", {
name: name,
avatar: name.charAt(0).toUpperCase(),
avatar: avatar,
role: role,
alert: alert,
});
Expand Down
2 changes: 1 addition & 1 deletion controllers/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Networks = async function(req, res) {
let containers = await docker.listContainers({ all: true });
// Loop through the containers to find out which networks are being used
for (let i = 0; i < containers.length; i++) {
console.log(Object.keys(containers[i].NetworkSettings.Networks)[0]);
// console.log(Object.keys(containers[i].NetworkSettings.Networks)[0]);
try { network_name += containers[i].HostConfig.NetworkMode; } catch {}
try { container_networks.push(containers[i].NetworkSettings.Networks[network_name].NetworkID); } catch {}
}
Expand Down
6 changes: 3 additions & 3 deletions router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ import { Uninstall } from "../utils/uninstall.js"
// Permission Middleware
const adminOnly = async (req, res, next) => {
if (req.session.role == 'admin') { next(); }
else if (no_auth && req.connection.remoteAddress == '::ffff:127.0.0.1') { next(); }
else if (no_auth && req.hostname == 'localhost') { next(); }
else { res.redirect('/dashboard'); }
}

const sessionCheck = async (req, res, next) => {
if (req.session.user) { next(); }
else if (no_auth && req.connection.remoteAddress == '::ffff:127.0.0.1') { next(); }
else if (no_auth && req.hostname == 'localhost') { next(); }
else { res.redirect('/login'); }
}

const permissionCheck = async (req, res, next) => {
if (req.session.role == 'admin') { next(); return; }
else if (no_auth && req.connection.remoteAddress == '::ffff:127.0.0.1') { next(); }
else if (no_auth && req.hostname == 'localhost') { next(); }
let user = req.session.user;
let action = req.path.split("/")[2];
let trigger = req.header('hx-trigger-name');
Expand Down

0 comments on commit 6c15c28

Please sign in to comment.