Skip to content

[Feature Request]: Allow using docker secrets to set values in the settings file #187

Description

@velvetpolygons

Enhancement of issue

I would like to be able to configure PeaNUT by using docker secrets to avoid having password in clear text in settings file.

Solution

Homepage use {{HOMEPAGE_VAR_X}} and {{HOMEPAGE_FILE_X}} and replace them in their config files.
https://gethomepage.dev/installation/docker/#using-environment-secrets
https://github.com/gethomepage/homepage/blob/dev/src/utils/config/config.js

I think a similar solution to it could work.
Settings:

NUT_SERVERS:
  - HOST: {{PEANUT_FILE_HOST}}
    PORT: {{PEANUT_FILE_PORT}}
    USERNAME: {{PEANUT_FILE_USERNAME}}
    PASSWORD: {{PEANUT_FILE_PASSWORD}}

Docker compose:

peanut:
    image: brandawg93/peanut:latest
    container_name: PeaNUT
    ports:
      - 8080:8080
    volumes:
      - /path/to/config:/config
    environment:
      - WEB_PORT=8080
      - PEANUT_FILE_HOST=/run/secrets/peanut-host
      - PEANUT_FILE_PORT=/run/secrets/peanut-port
      - PEANUT_FILE_USERNAME=/run/secrets/peanut-username
      - PEANUT_FILE_PASSWORD=/run/secrets/peanut-password
    secrets:
      - peanut-host
      - peanut-port
      - peanut-username
      - peanut-password

This works with multiple servers. Just add different environment variables for each server.

Alternatives

Configuring instantlinux/nut-upsd, I can set a secret as follows:

services:
  nut-upsd:
    image: instantlinux/nut-upsd
    container_name: nut-upsd
    environment:
      - DRIVER=usbhid-ups
    devices:
      - /dev/bus/usb:/dev/bus/usb
    secrets:
      - nut-upsd-password

Inside a bash script they read content of the file and sets the value of API_PASSWORD to it.
Later creates their configuration file from environment variables.
https://gitlab.com/instantlinux/docker-tools/-/blob/main/images/nut-upsd/entrypoint.sh

Could be harder to apply here if you wish to have more than one server.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions