Skip to content

Commit

Permalink
Merge pull request #9 from lllllllillllllillll/dev
Browse files Browse the repository at this point in the history
Merge dev into main for v0.04
  • Loading branch information
lllllllillllllillll authored Nov 11, 2023
2 parents 8621e12 + 0659999 commit 39bb048
Show file tree
Hide file tree
Showing 16 changed files with 3,033 additions and 133 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.04 (Nov 11th 2023)
* Docker Image and Compose file available.
* The containers DweebUI and DweebCache are hidden from the dashboard.
* Default icon for containers.
* Fixed missing information in container details/edit modals (Ports, Env, Volumes, Labels).

## v0.03 (Nov 5th 2023)
* Container graphs now load instantly on refresh
* Working net data for server dashboard
Expand Down
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# syntax=docker/dockerfile:1

# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/

ARG NODE_VERSION=20.0.0

FROM node:${NODE_VERSION}-alpine

# Use production node environment by default.
ENV NODE_ENV production


WORKDIR /app

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci --omit=dev

# Run the application as a non-root user.
USER root

# Copy the rest of the source files into the image.
COPY . .

# Expose the port that the application listens on.
EXPOSE 8000

# Run the application.
CMD node app.js
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

DweebUI is a simple Docker web interface created with javascript and node.js

Pre-Pre-Pre-Pre-Pre Alpha v 0.03 ( :fire: Experimental. Don't install on any servers you care about :fire: )
Pre-Pre-Pre-Pre-Pre Alpha v 0.04 ( :fire: Experimental. Don't install on any servers you care about :fire: )

* I haven't used Github very much and I'm still new to javascript
* I haven't used Github very much and I'm still new to javascript.
* This is the first project I've ever released and I'm sure it's full of plenty of bugs and mistakes.
* I probably should have waited a lot longer to share this :|

Requirements: Fresh Install of Debian 12.2
Requirements: Docker

![DweebUI](https://raw.githubusercontent.com/lllllllillllllillll/DweebUI/main/DweebUI.png)

Expand All @@ -26,8 +26,37 @@ Requirements: Fresh Install of Debian 12.2

## Setup

* Download and extract DweebUI.zip to a fresh Debian 12.2 Install
* Docker compose.yaml:
```
services:
  dweebui:
    container_name: DweebUI
    image: lllllllillllllillll/dweebui:v0.04
    ports:
      - 8000:8000
    depends_on:
      - cache
    links:
      - cache
    volumes:
      - dweebui:/app
      - /var/run/docker.sock:/var/run/docker.sock
  cache:
    container_name: DweebCache
    image: redis:6.2-alpine
    restart: always
    command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
    volumes:
      - cache:/data
 
volumes:
  dweebui:
  cache:
```

* Using setup.sh:
```
Extract DweebUI.zip and navigate to /DweebUI
cd DweebUI
chmod +x setup.sh
sudo ./setup.sh
Expand Down
5 changes: 2 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ const { serverStats, containerList, containerStats, containerAction } = require(
let sent_list, clicked;

const redisClient = require('redis').createClient({
host:'localhost',
port:6379,
password:'somesupersecretpassword',
url: 'redis://DweebCache:6379',
password:'eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81',
legacyMode:true
});
redisClient.connect().catch(console.log);
Expand Down
105 changes: 59 additions & 46 deletions components/dashCard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports.dashCard = function dashCard(data) {

let { name, service, id, state, image, external_port, internal_port } = data;
let { name, service, id, state, image, external_port, internal_port, ports, volumes, environment_variables, labels } = data;

//disable controls for a docker container depending on its name
let enabled = "";
Expand Down Expand Up @@ -32,77 +32,90 @@ module.exports.dashCard = function dashCard(data) {

let restart_policy = 'unless-stopped';


let ports_data = [];
for (let i = 0; i < 12; i++) {
if (ports) {
ports_data = ports;
} else {
for (let i = 0; i < 12; i++) {

let port_check = "checked";
let external = i;
let internal = i;
let protocol = "tcp";
let port_check = "checked";
let external = i;
let internal = i;
let protocol = "tcp";

ports_data.push({
check: port_check,
external: external,
internal: internal,
protocol: protocol
});
ports_data.push({
check: port_check,
external: external,
internal: internal,
protocol: protocol
});
}
}


let volumes_data = [];
for (let i = 0; i < 12; i++) {
if (volumes) {
volumes_data = volumes;
} else {
for (let i = 0; i < 12; i++) {

let vol_check = "checked";
let bind = i;
let container = i;
let readwrite = "rw";
let vol_check = "checked";
let bind = i;
let container = i;
let readwrite = "rw";

volumes_data.push({
check: vol_check,
bind: bind,
container: container,
readwrite: readwrite
});
volumes_data.push({
check: vol_check,
bind: bind,
container: container,
readwrite: readwrite
});
}
}


let env_data = [];
for (let i = 0; i < 12; i++) {
if (environment_variables) {
env_data = environment_variables;
} else {
for (let i = 0; i < 12; i++) {

let env_check = "checked";
let env_name = i;
let env_default = i;
let env_check = "checked";
let env_name = i;
let env_default = i;

env_data.push({
env_check: env_check,
env_name: env_name,
env_default: env_default
});
env_data.push({
check: env_check,
name: env_name,
default: env_default
});
}
}


let label_data = [];
for (let i = 0; i < 12; i++) {
if (labels) {
label_data = labels;
} else {
for (let i = 0; i < 12; i++) {

let label_check = "checked";
let label_name = i;
let label_default = i;

label_data.push({
label_check: label_check,
label_name: label_name,
label_default: label_default
});
let label_check = "checked";
let label_name = i;
let label_default = i;

label_data.push({
check: label_check,
name: label_name,
value: label_default
});
}
}


return `
<div class="col-sm-6 col-lg-3 deleteme">
<div class="card">
<div class="card-body">
<div class="card-stamp card-stamp-sm">
<img heigh="150px" width="150px" src="https://raw.githubusercontent.com/lllllllillllllillll/DweebUI-Icons/main/${service}.png"></img>
<img heigh="150px" width="150px" src="https://raw.githubusercontent.com/lllllllillllllillll/DweebUI-Icons/main/${service}.png" onerror="this.onerror=null;this.src='https://raw.githubusercontent.com/lllllllillllllillll/DweebUI-Icons/main/dweebui.png';"></img>
</div>
<div class="d-flex align-items-center">
Expand Down
27 changes: 27 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
dweebui:
container_name: DweebUI
build:
context: .
environment:
NODE_ENV: production
ports:
- 8000:8000
depends_on:
- cache
links:
- cache
volumes:
- dweebui:/app
- /var/run/docker.sock:/var/run/docker.sock
cache:
container_name: DweebCache
image: redis:6.2-alpine
restart: always
command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
volumes:
- cache:/data

volumes:
dweebui:
cache:
16 changes: 5 additions & 11 deletions controllers/apps.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const User = require('../database/UserModel');
const { appCard } = require('../components/appCard')
const { exec, execSync } = require("child_process");
const { dashCard } = require('../components/dashCard');
const yaml = require('js-yaml');

const { install } = require('../functions/package_manager');
const { install, uninstall } = require('../functions/package_manager');

// import { install, uninstall } from '../functions/package_manager';

const templates_json = require('../templates.json');
let templates = templates_json.templates;
Expand All @@ -29,7 +28,6 @@ exports.Apps = async function(req, res) {
let list_end = (page * 28);
let last_page = Math.ceil(templates.length / 28);

// generate values for prev and next buttons so that i can go back and forth between pages
let prev = '/apps?page=' + (page - 1);
let next = '/apps?page=' + (page + 1);
if (page == 1) {
Expand Down Expand Up @@ -78,7 +76,6 @@ exports.searchApps = async function(req, res) {
let list_end = (page * 28);
let last_page = Math.ceil(templates.length / 28);

// generate values for prev and next buttons so that i can go back and forth between pages
let prev = '/apps?page=' + (page - 1);
let next = '/apps?page=' + (page + 1);
if (page == 1) {
Expand All @@ -95,7 +92,6 @@ exports.searchApps = async function(req, res) {

// split value of search into an array of words
search = search.split(' ');

try {console.log(search[0]);} catch (error) {}
try {console.log(search[1]);} catch (error) {}
try {console.log(search[2]);} catch (error) {}
Expand Down Expand Up @@ -179,11 +175,9 @@ exports.Uninstall = async function (req, res) {


if (req.body.confirm == 'Yes') {
exec(`docker compose -f ./appdata/${req.body.service_name}/docker-compose.yml down`, (error, stdout, stderr) => {
if (error) { console.error(`error: ${error.message}`); return; }
if (stderr) { console.error(`stderr: ${stderr}`); return; }
console.log(`stdout:\n${stdout}`);
});

uninstall(req.body);

}


Expand Down
2 changes: 0 additions & 2 deletions controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ exports.processRegister = async function(req,res){
avatar: `<img src="./static/avatars/${avatar}">`
});

console.log(`Created: ${user.first_name}`);

// set the session.
req.session.user = user.username;
req.session.UUID = user.UUID;
Expand Down
2 changes: 1 addition & 1 deletion database/ServerSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { Sequelize, DataTypes } = require('sequelize');

const sequelize = new Sequelize({
dialect: 'sqlite',
storage: 'database/db.sqlite',
storage: './database/db.sqlite',
logging: false
});

Expand Down
2 changes: 1 addition & 1 deletion database/UserModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { Sequelize, DataTypes } = require('sequelize');

const sequelize = new Sequelize({
dialect: 'sqlite',
storage: 'database/db.sqlite',
storage: './database/db.sqlite',
logging: false
});

Expand Down
Loading

0 comments on commit 39bb048

Please sign in to comment.