浏览代码

ADD: App Pi-Hole + Unbound

Nicolas Meienberger 3 年之前
父节点
当前提交
5716a38dff

+ 20 - 0
apps/pi-hole/config.json

@@ -0,0 +1,20 @@
+{
+    "name": "PiHole",
+    "id": "pi-hole",
+    "description": "",
+    "short_desc": "",
+    "author": "",
+    "source": "",
+    "image": "https://avatars.githubusercontent.com/u/16827203?s=200&v=4",
+    "form_fields": {
+      "password": {
+        "type": "password",
+        "label": "Password",
+        "max": 50,
+        "min": 3,
+        "required": true,
+        "env_variable": "APP_PASSWORD"
+      }
+    }
+  }
+  

+ 0 - 0
apps/pi-hole/data/unbound/unbound.conf → apps/pi-hole/data/unbound_old/unbound_old.conf


+ 24 - 20
apps/pi-hole/docker-compose.yml

@@ -1,34 +1,38 @@
 version: "3.7"
 
 services:
-  unbound:
-    user: '1000:1000'
-    image: "klutchell/unbound:latest"
-    volumes:
-      - ${APP_DATA_DIR}/data/unbound:/etc/unbound
-    networks:
-        - tipi_main_network
+  # unbound:
+  #   container_name: unbound
+  #   mac_address: d0:ca:ab:cd:ef:02
+  #   image: mvance/unbound:latest
+  #   ports:
+  #     - 53/tcp
+  #     - 53/udp
+  #   volumes:
+  #     - ${APP_DATA_DIR}/data/unbound:/etc/unbound
+  #   networks:
+  #     - tipi_main_network
   
-  pihole:
-    image: pihole/pihole
+  pi-hole:
+    container_name: pi-hole
+    image: cbcrowe/pihole-unbound:latest
     restart: on-failure
     ports:
-      - 53:53
+      - 53:53/tcp
       - 53:53/udp
       - ${APP_PI_HOLE_PORT}:80
     volumes:
       - ${APP_DATA_DIR}/data/pihole:/etc/pihole/
       - ${APP_DATA_DIR}/data/dnsmasq:/etc/dnsmasq.d/
+      - ${APP_DATA_DIR}/data/unbound:/etc/unbound/
     environment:
-      - VIRTUAL_HOST="pihole.${DOMAIN}"
-      - WEBPASSWORD=${APP_PASSWORD}
-      - PIHOLE_DNS=unbound
-    depends_on:
-      - unbound
+      TZ: ${TZ}
+      WEBPASSWORD: ${APP_PASSWORD}
+      PIHOLE_DNS_: 127.0.0.1#5335
     networks:
-        - tipi_main_network
-    labels:
-      traefik.enable: true
-      traefik.http.routers.traefik.rule: Host(`pihole.${DOMAIN}`)
-      traefik.http.services.traefik.loadbalancer.server.port: $APP_PI_HOLE_PORT
+      - tipi_main_network
+    # labels:
+    #   traefik.enable: true
+    #   traefik.http.routers.traefik.rule: Host(`pihole.${DOMAIN}`)
+    #   traefik.http.services.traefik.loadbalancer.server.port: $APP_PI_HOLE_PORT
 

+ 12 - 0
dashboard/Dockerfile.dev

@@ -0,0 +1,12 @@
+FROM node:latest
+
+WORKDIR /app
+
+COPY ./package.json ./
+COPY ./yarn.lock ./
+
+RUN yarn
+
+COPY ./ ./
+
+CMD ["yarn", "dev"]

+ 1 - 1
dashboard/src/core/api.ts

@@ -1,6 +1,6 @@
 import axios, { Method } from 'axios';
 
-const BASE_URL = 'http://192.168.2.146:3001';
+const BASE_URL = 'http://localhost:3001';
 
 interface IFetchParams {
   endpoint: string;

+ 0 - 1
docker-compose.yml

@@ -42,7 +42,6 @@ services:
     container_name: dashboard
     volumes:
       - ${PWD}/state:/app/state
-      - ${PWD}/config:/app/config:ro
     ports:
       - 3000:3000
     networks:

+ 3 - 0
scripts/app.sh

@@ -106,6 +106,9 @@ compose() {
 if [[ "$command" = "install" ]]; then
   compose "${app}" pull
 
+  # Copy default data dir to app data dir
+  cp -r "${ROOT_FOLDER}/apps/${app}/data" "${app_data_dir}/data"
+
   compose "${app}" up -d
   exit
 fi

+ 1 - 1
state/apps.json

@@ -1 +1 @@
-{"installed":" transmission radarr jellyfin","environment":{"anonaddy":{}}}
+{"installed":" pi-hole","environment":{"anonaddy":{}}}

+ 1 - 1
system-api/src/config/apps.ts

@@ -1 +1 @@
-export const appNames = ['nextcloud', 'freshrss', 'anonaddy', 'filerun', 'wg-easy', 'radarr', 'transmission', 'jellyfin'];
+export const appNames = ['nextcloud', 'freshrss', 'anonaddy', 'filerun', 'wg-easy', 'radarr', 'transmission', 'jellyfin', 'pi-hole'];

+ 5 - 7
system-api/src/modules/apps/apps.controller.ts

@@ -1,4 +1,4 @@
-import { Request, Response } from 'express';
+import { NextFunction, Request, Response } from 'express';
 import si from 'systeminformation';
 import { appNames } from '../../config/apps';
 import { AppConfig } from '../../config/types';
@@ -35,7 +35,7 @@ const generateEnvFile = (appName: string, form: Record<string, string>) => {
   writeFile(`/app-data/${appName}/app.env`, envFile);
 };
 
-const installApp = (req: Request, res: Response) => {
+const installApp = (req: Request, res: Response, next: NextFunction) => {
   try {
     const { id } = req.params;
     const { form } = req.body;
@@ -76,11 +76,11 @@ const installApp = (req: Request, res: Response) => {
       res.status(200).json({ message: 'App installed successfully' });
     });
   } catch (e) {
-    res.status(500).send(e);
+    next(e);
   }
 };
 
-const uninstallApp = (req: Request, res: Response) => {
+const uninstallApp = (req: Request, res: Response, next: NextFunction) => {
   try {
     const { id: appName } = req.params;
 
@@ -106,12 +106,10 @@ const uninstallApp = (req: Request, res: Response) => {
         throw new Error(err);
       }
 
-      deleteFolder(`/app-data/${appName}`);
-
       res.status(200).json({ message: 'App uninstalled successfully' });
     });
   } catch (e) {
-    res.status(500).send(e);
+    next(e);
   }
 };
 

+ 6 - 0
system-api/src/server.ts

@@ -21,6 +21,12 @@ app.use(cors());
 app.use('/system', systemRoutes);
 app.use('/apps', appsRoutes);
 
+app.use((err, req, res, next) => {
+  // logic
+  console.error('Middleware', err);
+  res.status(500).send('Something broke!');
+});
+
 app.listen(port, () => {
   console.log(`System API listening on port ${port}`);
 });