linuxserver / docker-unifi-network-application

GNU General Public License v3.0
553 stars 41 forks source link

[BUG] Using secret from files causes sed error #30

Closed doman18 closed 4 months ago

doman18 commented 7 months ago

Is there an existing issue for this?

Current Behavior

I tried to use secrets in files. Mongo database was created/started from separate docker compose but shares the same network as unifi app in main docker-compose.yml. Sed seems to have some problems with parsing secret files and thus i get 404. Also I see system.properties file does not have replaced values.

statdb.mongo.uri=mongodb\://~MONGO_USER~\:~MONGO_PASS~@mongo-unifi-bitnami\:27017/~MONGO_DBNAME~_stat?tls\=false&authSource\=~MONGO_AUTHSOURCE~
reporter-uuid=
unifi.db.name=~MONGO_DBNAME~
debug.device=warn
debug.mgmt=warn
db.mongo.local=false
debug.setting_preference=auto
uuid=7732c318-f041-47ed-bfdc-c1396a2ffe2e
debug.system=warn
db.mongo.uri=mongodb\://~MONGO_USER~\:~MONGO_PASS~@mongo-unifi-bitnami\:27017/~MONGO_DBNAME~?tls\=false&authSource\=~MONGO_AUTHSOURCE~
debug.sdn=warn

Expected Behavior

No response

Steps To Reproduce

Basically its just creating text files in secrets folder (like /home/app/docker-volumes/unifi/secrets/mongodb_user.txt in my case)

Environment

- OS: 22.04
- How docker service was installed: with official guide (adding sources.list etc)

CPU architecture

x86-64

Docker creation

# docker-compose.yml
services:
  unifi-controller:
    container_name: unifi-controller
    environment:
      FILE__MONGO_DBNAME: /run/secrets/mongodb_name
      FILE__MONGO_PASS: /run/secrets/mongodb_password
      FILE__MONGO_USER: /run/secrets/mongodb_user
      MONGO_HOST: mongo-unifi-bitnami
      MONGO_PORT: "27017"
      PGID: "1001"
      PUID: "1001"
      TZ: CET
    image: lscr.io/linuxserver/unifi-network-application:7.5.187
    networks:
      dominiknet: null
      mongonet: null
    ports:
    - mode: ingress
      target: 3478
      published: "3478"
      protocol: udp
    - mode: ingress
      target: 10001
      published: "10001"
      protocol: udp
    - mode: ingress
      target: 8080
      published: "8080"
      protocol: tcp
    - mode: ingress
      target: 8443
      published: "8443"
      protocol: tcp
    - mode: ingress
      target: 8843
      published: "8843"
      protocol: tcp
    - mode: ingress
      target: 8880
      published: "8880"
      protocol: tcp
    restart: always
    secrets:
    - source: mongodb_user
    - source: mongodb_password
    - source: mongodb_name
    volumes:
    - type: bind
      source: /home/app/docker-volumes/unifi/controller
      target: /config
      bind:
        create_host_path: true
networks:
  dominiknet:
    name: reverse_proxy_network
    external: true
  mongonet:
    name: unifi_mongodb_network
    external: true
secrets:
  mongodb_name:
    name: unifi_mongodb_name
    file: /home/app/docker-volumes/unifi/secrets/mongodb_name.txt
  mongodb_password:
    name: unifi_mongodb_password
    file: /home/app/docker-volumes/unifi/secrets/mongodb_password.txt
  mongodb_user:
    name: unifi_mongodb_user
    file: /home/app/docker-volumes/unifi/secrets/mongodb_user.txt

# docker-compose-db.yml
services:
  mongo-unifi:
    container_name: mongo-unifi-bitnami
    environment:
      MONGODB_DATABASE_FILE: /run/secrets/mongodb_name
      MONGODB_PASSWORD_FILE: /run/secrets/mongodb_password
      MONGODB_ROOT_PASSWORD_FILE: /run/secrets/mongodb_root_pwd
      MONGODB_SYSTEM_LOG_VERBOSITY: "5"
      MONGODB_USERNAME_FILE: /run/secrets/mongodb_user
    image: bitnami/mongodb:4.2.21-debian-10-r8
    networks:
      mongonet: null
    restart: always
    secrets:
    - source: mongodb_user
    - source: mongodb_password
    - source: mongodb_name
    - source: mongodb_root_pwd
    volumes:
    - type: bind
      source: /home/app/docker-volumes/unifi/mongodb-bitnami
      target: /bitnami/mongodb
      bind:
        create_host_path: true
    - type: bind
      source: /home/app/docker-volumes/unifi/mongodb-initdb
      target: /docker-entrypoint-initdb.d
      bind:
        create_host_path: true
networks:
  mongonet:
    name: unifi_mongodb_network
secrets:
  mongodb_name:
    name: unifi_mongodb_name
    file: /home/app/docker-volumes/unifi/secrets/mongodb_name.txt
  mongodb_password:
    name: unifi_mongodb_password
    file: /home/app/docker-volumes/unifi/secrets/mongodb_password.txt
  mongodb_root_pwd:
    name: unifi_mongodb_root_pwd
    file: /home/app/docker-volumes/unifi/secrets/mongodb_root_password.txt
  mongodb_user:
    name: unifi_mongodb_user
    file: /home/app/docker-volumes/unifi/secrets/mongodb_user.txt

Container logs

[migrations] started
[migrations] no migrations found
[env-init] MONGO_DBNAME set from FILE__MONGO_DBNAME
[env-init] MONGO_PASS set from FILE__MONGO_PASS
[env-init] MONGO_USER set from FILE__MONGO_USER
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1001
User GID:    1001
───────────────────────────────────────

*** Waiting for MONGO_HOST mongo-unifi-bitnami to be reachable. ***
sed: -e expression #1, char 38: unterminated `s' command
sed: -e expression #1, char 36: unterminated `s' command
sed: -e expression #1, char 40: unterminated `s' command
sed: -e expression #1, char 40: unterminated `s' command
Generating 4,096 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 3,650 days
    for: CN=unifi
[custom-init] No custom files found, skipping...
no crontab for abc
no crontab for root
github-actions[bot] commented 7 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

LinuxServer-CI commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 3 months ago

This issue is locked due to inactivity