plugsy / core

A simple, pluggable dashboard and status page
161 stars 4 forks source link

Move config to directory so we can properly use volumes #46

Open airtonix opened 2 years ago

airtonix commented 2 years ago

I'd like to configure plugsy configuration to be stored in anamed volume, but you dictate that the config.json is in the root of the filesystem.

the syntax for declaring named volumes implies they are like folders :

🛑 bad

  volumes:
    - plugsy_service_config_volume/config.json:/config.json

💚 Better

  volumes:
    - plugsy_service_config_volume:/opt/plugsy/config/

👇🏻 My desired configuration

version: "3.3"

services:
  plugsy:
    restart: unless-stopped
    image: plugsy/core
    labels:
      traefik.http.routers.piehole-ui-router.service: plugsy-ui-service
      traefik.http.routers.plugsy-ui-router.rule: Host(`the.home.lan`)
      traefik.http.services.plugsy-ui-service.loadbalancer.server.port: 3000
    volumes:
      - plugsy_service_config_volume:/opt/plugsy/config/
      - /var/run/docker.sock:/var/run/docker.sock

volumes:
  plugsy_service_config_volume:

networks:
  default:
    external:
      name: traefik_proxy

I make editing these things easy by using codeserver to mount all the volumes that my services use.

Mikle-Bond commented 1 year ago

There is a workaround to this issue. You can use (somewhat undocumented) environment variable PLUGSY_LOCAL_CONFIG_FILE to point to custom location. Like this:

services:
  plugsy:
    image: plugsy/core
    environment:
      - PLUGSY_LOCAL_CONFIG_FILE=/config/config.json
    volumes:
      - ./plugsy:/config
    expose:
      - "3000/tcp"
    labels:
      caddy: import rproxy plugsy "{{upstreams 3000}}"

# ... etc ...
samcro1967 commented 6 months ago

I just created the file locally and mounted it to the container:

  plugsy:
    hostname: plugsy
    image: plugsy/core:latest
    container_name: plugsy
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${docker}/plugsy/config.json:/config.json
    ports:
      - 8130:3000
Mikle-Bond commented 6 months ago

@samcro1967 we don't want to mount files. We want to mount directories. Mounting files triggers a number of funny issues.

Inlustra commented 6 months ago

I actually had no idea that was the reason! Thanks you for posting the link @Mikle-Bond

I still use Plugsy on the daily as my homepage, I'll look at fixing this when I get some time to get into it... Apologies for the late reply on this.

Inlustra commented 6 months ago

Thinking about the solution to this .. it's already in the code as mentioned previously by @Mikle-Bond.

  plugsy:
    hostname: plugsy
    image: plugsy/core:latest
    container_name: plugsy
    restart: always
    environment:
      - PLUGSY_LOCAL_CONFIG_FILE=/whatever/config json
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${docker}/plugsy:/whatever
    ports:
      - 8130:3000

That does solve this issue right? I'll get this added to the docs, and maybe look at changing the default to a folder mount