Coder Social home page Coder Social logo

Comments (14)

holyjak avatar holyjak commented on July 23, 2024

I have looked little more into at and found out there is no ENV_DIR to pass on. The host machine has the file /home/dokku/<app name>/ENV with lines like export MY_VAR=something and the dokku script copies that into <container>/app/.profile.d/app-env.sh in the release phase - so the ENV is not available in the container during build/compile.

I guess that one way to "fix" this would be to propagate ENV to the container already before /build/builder is invoked and source it before executing builder or have builder sourcing it itself. The question is if we want to make all vars available at compile time (or only some of them).

Some background: Clojure code may contain macros that may be executed at compile time - and some macros may depend on the environment (f.ex. needing a path to a directory with template files).

from buildstep.

asm89 avatar asm89 commented on July 23, 2024

@jakubholynet Are you using dokku? If yes one of these plugins might help you:
https://github.com/musicglue/dokku-user-env-compile
https://github.com/motin/dokku-user-env-compile

See: https://github.com/progrium/dokku/wiki/Plugins

from buildstep.

holyjak avatar holyjak commented on July 23, 2024

Thank you very much! Yes, I use Dokku. I will check out the plugins.

from buildstep.

holyjak avatar holyjak commented on July 23, 2024

Note: the Dokku plugins mirror the now deprecated Heroku lab feature user-env-compile, that has been replaced by the ENV_DIR argument as described on that page an in the Heroku Buildpack API.

It would be nice if Dokku replicated the change.

from buildstep.

 avatar commented on July 23, 2024

I'd accept a PR for it on dokku's side

from buildstep.

holyjak avatar holyjak commented on July 23, 2024

Great!
What would be a good implementation? I suppose that we want to keep the ENV file for backwards compatibility so enhancing dokku build to create /app/.env.d/ with a file for each env var based on parsing ENV would be likely a good solution?

from buildstep.

fmd avatar fmd commented on July 23, 2024

Is there any chance we could then load these env vars into /exec? Any reason that wouldn't be a good idea?

from buildstep.

stuartpb avatar stuartpb commented on July 23, 2024

@jakubholynet I don't know about putting it in /app - I think it would make more sense to put it in a top-level directory like /cache, which gets removed (as a volume or as part of the docker run command) immediately after building (and then not touching /app/.profile.d/app-env.sh).

Anyway, if you're putting it in, say, /env, then you could do something like this for Dokku without changing the ENV format:

docker run progrium/buildstep bash -c "
`sed 's/^export \([^=]\)=\(.*\)$/echo \2 > /env/\1/' <"$APP_DIR/ENV"`
/builder/build
# and, optionally
rm -rf /env"

from buildstep.

stuartpb avatar stuartpb commented on July 23, 2024

Anyway, the way we're looking at doing this in plushu/plusku, it would be best if /build/builder looked for a /env directory, then called compile with it as a third parameter if it's present. (Alternately, it could just mkdir -p /env and let the buildpack freak out if nobody populated /env, which would probably be at least as smooth as the behavior when $3 is undefined.)

from buildstep.

progrium avatar progrium commented on July 23, 2024

ENV_DIR for buildpacks is supported in the herokuish branch here. Can you try against that version?

from buildstep.

holyjak avatar holyjak commented on July 23, 2024

Nice. It is not easy for me anymore to try this out since I am away from the project where I experienced the problem but I will try to find the time to try to replicate it.

from buildstep.

progrium avatar progrium commented on July 23, 2024

Thank you :)

from buildstep.

mjonuschat avatar mjonuschat commented on July 23, 2024

BTW, the ENV_DIR is also supported in the current buildstep image, no idea if dokku etc. are using it though..

from buildstep.

vincentfretin avatar vincentfretin commented on July 23, 2024

@yabawock Yes, Dokku supports ENV_DIR since dokku/dokku@7d5e0ba

from buildstep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.