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
  • Brite
  • 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 - Status | 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 2.8k 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

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    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