Forráskód Böngészése

Merge pull request #111 from pawelmalak/remote-host

Version 1.6.9
pawelmalak 3 éve
szülő
commit
fc219f704c

+ 1 - 1
.env

@@ -1,3 +1,3 @@
 PORT=5005
 NODE_ENV=development
-VERSION=1.6.8
+VERSION=1.6.9

+ 3 - 0
CHANGELOG.md

@@ -1,3 +1,6 @@
+### v1.6.9 (2021-10-09)
+- Added option for remote docker host ([#97](https://github.com/pawelmalak/flame/issues/97))
+
 ### v1.6.8 (2021-10-05)
 - Implemented migration system for database
 

+ 24 - 15
README.md

@@ -150,20 +150,6 @@ To use search bar you need to type your search query with selected prefix. For e
 2. Get lat/long for your location. You can get them from [latlong.net](https://www.latlong.net/convert-address-to-lat-long.html).
 3. Enter and save data. Weather widget will now update and should be visible on Home page.
 
-### Supported URL formats for applications and bookmarks
-
-#### Rules
-
-- URL starts with `http://`
-  - Format: `http://www.domain.com`, `http://domain.com`
-  - Redirect: `{dest}`
-- URL starts with `https://`
-  - Format: `https://www.domain.com`, `https://domain.com`
-  - Redirect: `https://{dest}`
-- URL without protocol
-  - Format: `www.domain.com`, `domain.com`, `sub.domain.com`, `local`, `ip`, `ip:port`
-  - Redirect: `http://{dest}`
-
 ### Docker integration
 
 In order to use the Docker integration, each container must have the following labels:
@@ -177,6 +163,8 @@ labels:
 # - flame.icon=custom to make changes in app. ie: custom icon upload
 ```
 
+And you must have activated the Docker sync option in the settings panel.
+
 You can set up different apps in the same label adding `;` between each one.
 
 ```yml
@@ -187,7 +175,28 @@ labels:
   - flame.icon=icon-name1;icon-name2
 ```
 
-And you must have activated the Docker sync option in the settings panel.
+If you want to use a remote docker host follow this instructions in the host:
+
+- Open the file `/lib/systemd/system/docker.service`, search for `ExecStart` and edit the value
+
+```text
+ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:${PORT} -H unix:///var/run/docker.sock
+```
+
+>The above command will bind the docker engine server to the Unix socket as well as TCP port of your choice. “0.0.0.0” means docker-engine accepts connections from all IP addresses.
+
+- Restart the daemon and Docker service
+
+```shell
+sudo systemctl daemon-reload
+sudo service docker restart
+```
+
+- Test if it is working
+
+```shell
+curl http://${IP}:${PORT}/version
+```
 
 ### Kubernetes integration
 

+ 1 - 1
client/.env

@@ -1 +1 @@
-REACT_APP_VERSION=1.6.8
+REACT_APP_VERSION=1.6.9

+ 13 - 0
client/src/components/Settings/OtherSettings/OtherSettings.tsx

@@ -52,6 +52,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
     bookmarksSameTab: 0,
     searchSameTab: 0,
     dockerApps: 1,
+    dockerHost: 'localhost',
     kubernetesApps: 1,
     unpinStoppedApps: 1,
   });
@@ -72,6 +73,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
       bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
       searchSameTab: searchConfig('searchSameTab', 0),
       dockerApps: searchConfig('dockerApps', 0),
+      dockerHost: searchConfig('dockerHost', 'localhost'),
       kubernetesApps: searchConfig('kubernetesApps', 0),
       unpinStoppedApps: searchConfig('unpinStoppedApps', 0),
     });
@@ -275,6 +277,17 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
 
       {/* DOCKER SETTINGS */}
       <h2 className={classes.SettingsSection}>Docker</h2>
+      <InputGroup>
+        <label htmlFor="dockerHost">Docker Host</label>
+        <input
+          type="text"
+          id="dockerHost"
+          name="dockerHost"
+          placeholder="dockerHost:port"
+          value={formData.dockerHost}
+          onChange={(e) => inputChangeHandler(e)}
+        />
+      </InputGroup>
       <InputGroup>
         <label htmlFor="dockerApps">Use Docker API</label>
         <select

+ 1 - 0
client/src/interfaces/Forms.ts

@@ -19,6 +19,7 @@ export interface SettingsForm {
   bookmarksSameTab: number;
   searchSameTab: number;
   dockerApps: number;
+  dockerHost: string;
   kubernetesApps: number;
   unpinStoppedApps: number;
 }

+ 19 - 8
controllers/apps.js

@@ -65,16 +65,27 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
   if (useDockerApi && useDockerApi.value == 1) {
     let containers = null;
 
+    const host = await Config.findOne({
+      where: { key: 'dockerHost' },
+    });
+
     try {
-      let { data } = await axios.get(
-        'http://localhost/containers/json?{"status":["running"]}',
-        {
-          socketPath: '/var/run/docker.sock',
-        }
-      );
-      containers = data;
+      if (host.value.includes('localhost')) {
+        let { data } = await axios.get(
+          `http://${host.value}/containers/json?{"status":["running"]}`,
+          {
+            socketPath: '/var/run/docker.sock',
+          }
+        );
+        containers = data;
+      } else {
+        let { data } = await axios.get(
+          `http://${host.value}/containers/json?{"status":["running"]}`
+        );
+        containers = data;
+      }
     } catch {
-      logger.log("Can't connect to the docker socket", 'ERROR');
+      logger.log(`Can't connect to the docker api on ${host.value}`, 'ERROR');
     }
 
     if (containers) {

+ 4 - 0
utils/initialConfig.json

@@ -68,6 +68,10 @@
       "key": "dockerApps",
       "value": false
     },
+    {
+      "key": "dockerHost",
+      "value": "localhost"
+    },
     {
       "key": "kubernetesApps",
       "value": false