Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Support
  3. Reading env variables with custom app

Reading env variables with custom app

Scheduled Pinned Locked Moved Solved Support
custom apps
9 Posts 2 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ekevu123
    wrote on last edited by girish
    #1

    I am trying to install a custom app written in Phoenix Elixir.

    My dockerfile ends with that:

    ADD start.sh /app/start.sh
    RUN chmod +x /app/start.sh
    CMD [ "/app/start.sh" ]
    

    Earlier, I set my environment variables like that:

    ENV SECRET_KEY_BASE=default
    

    Here is my startup script:

    #!/bin/bash
    
    set -eu
    
    # Load environment variables
    source ./env.list
    
    # Start PROGRAM
    exec ./_build/prod/rel/PROGRAM/bin/PROGRAM start
    

    But the environment variables don't seem to be read properly, so the app doesn't start in Cloudron. What am I doing wrong?

    1 Reply Last reply
    1
    • robiR Offline
      robiR Offline
      robi
      wrote on last edited by
      #2

      are they set in env.list ?

      Conscious tech

      1 Reply Last reply
      1
      • E Offline
        E Offline
        ekevu123
        wrote on last edited by
        #3

        Yes, in this format:
        SECRET_KEY_BASE=KEY

        I learned now that I can run them via Cloudron CLI using cloudron set env, but I wonder if it was still possible to do that automatically.

        1 Reply Last reply
        0
        • robiR Offline
          robiR Offline
          robi
          wrote on last edited by
          #4

          what if you included them as part of the exec?

          Conscious tech

          1 Reply Last reply
          0
          • E Offline
            E Offline
            ekevu123
            wrote on last edited by
            #5

            Do you mean to put the exact keys into the dockerfile? I tried that with ENV SECRET_KEY_BASE=KEY, but it didn't work.

            1 Reply Last reply
            0
            • robiR Offline
              robiR Offline
              robi
              wrote on last edited by
              #6

              No, that's a different part of the build/install process.

              The envs need to be available as you launch the app.

              Conscious tech

              1 Reply Last reply
              1
              • E Offline
                E Offline
                ekevu123
                wrote on last edited by
                #7

                How would this look like then?

                1 Reply Last reply
                0
                • robiR Offline
                  robiR Offline
                  robi
                  wrote on last edited by
                  #8

                  First, I'd define them explicitly in the startup script, to see if the exec can see them then.

                  So instead of source .env , export ENV=KEY

                  Conscious tech

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    ekevu123
                    wrote on last edited by
                    #9

                    Yes, that works, thank you!

                    1 Reply Last reply
                    0
                    • girishG girish marked this topic as a question on
                    • girishG girish has marked this topic as solved on
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Bookmarks
                    • Search