tagem icon indicating copy to clipboard operation
tagem copied to clipboard

Use docker environment variables instead of tagem-auth.cfg file

Open tehniemer opened this issue 5 years ago • 5 comments

Can you make the targets in the .cfg file environment variables like shown in the config file below? It seems many other containers use the format below to pass login info to a database instance and it works pretty slick. Maybe an either or thing for those that aren't using compose and would rather use a local file.

  tagem:
    image: notcompsky/tagem:latest
    container_name: tagem
    restart: always
    networks:
      - proxy
      - tagem
    volumes:
      - /etc/localtime:/etc/localtime:ro
    security_opt:
      - no-new-privileges:true
    ports:
      - "$TAGEM_PORT:80"
    environment:
      MYSQL_HOSTNAME: tagemdb
      MYSQL_PORT: $DB_PORT
      MYSQL_DATABASE: db
      MYSQL_USER: tagem
      MYSQL_PASSWORD: $USER_PASS
    depends_on:
     - tagemdb

tehniemer avatar Jul 28 '20 13:07 tehniemer

I've never used Docker Compose or LinuxServer so I'm not sure I understand what you're asking.

But this compose file will fail to run because the cfg file is being loaded onto the container in the root directory, while the environmental variable TAGEM_MYSQL_CFG - which should point to that cfg file - instead points to the location of the cfg file on the server, rather than the location it is mapped to on the container.

Do you want that environmental variable to be set by default? Again sorry for not understanding the question, that's just my lack of knowledge, I'm still happy to fix the issue if you see a problem.

NotCompsky avatar Jul 28 '20 16:07 NotCompsky

My thought was that environment variables could be used instead of the tagem-auth.cfg file. That way the file doesn't need to exist and the relevant information can be passed to the container during creation.

tehniemer avatar Jul 30 '20 18:07 tehniemer

This is how the database would be set up in the compose file, you can see how the environment variables match up to the environment variables in the example I posted above.

  tagemdb:
    image: linuxserver/mariadb:latest
    container_name: tagemdb
    hostname: tagemdb
    restart: always
    networks:
      - tagem
    security_opt:
      - no-new-privileges:true
    volumes:
      - $CONFIG_DIR/tagem/db:/config
      - /etc/localtime:/etc/localtime:ro
    environment:
      PUID: $PUID
      PGID: $PGID
      MYSQL_ROOT_PASSWORD: $ROOT_PASS
      MYSQL_DATABASE: db
      MYSQL_USER: tagem
      MYSQL_PASSWORD: $USER_PASS
      MYSQL_ROOT_HOST: "%"

tehniemer avatar Jul 30 '20 23:07 tehniemer

My thought was that environment variables could be used instead of the tagem-auth.cfg file. That way the file doesn't need to exist and the relevant information can be passed to the container during creation.

Thanks for the title change, it's a lot clearer now.

Your request is reasonable, and I will try to implement it. It should be fairly simple to do.

The question I have though is whether it would be as easy to have them as command-line arguments rather than environmental variables?

NotCompsky avatar Aug 01 '20 13:08 NotCompsky

You can also set environment variables in the command line, you don't need to use compose. This way also gives the option of an environment file, so you could still have an option of using a file like you have currently, it would just need to be formatted differently.

https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file

tehniemer avatar Aug 01 '20 13:08 tehniemer