core icon indicating copy to clipboard operation
core copied to clipboard

Move config to directory so we can properly use volumes

Open airtonix opened this issue 2 years ago • 5 comments

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.

airtonix avatar Jul 17 '22 03:07 airtonix

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 ...

Mikle-Bond avatar Nov 27 '22 17:11 Mikle-Bond

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

samcro1967 avatar Jan 06 '24 15:01 samcro1967

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

Mikle-Bond avatar Jan 07 '24 10:01 Mikle-Bond

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 avatar Jan 07 '24 22:01 Inlustra

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

Inlustra avatar Jan 10 '24 00:01 Inlustra