Coder Social home page Coder Social logo

Support of env_file ? about sbt-docker-compose HOT 15 CLOSED

Cowa avatar Cowa commented on September 27, 2024
Support of env_file ?

from sbt-docker-compose.

Comments (15)

Cowa avatar Cowa commented on September 27, 2024 1

Yeah! It works by removing dockerComposeInstances.bin, thanks @tobym.

@kurtkopchik All is okay with this new snapshot too.

Well, everything seems fine now. Thank you again to both of you 👍

from sbt-docker-compose.

kurtkopchik avatar kurtkopchik commented on September 27, 2024

Hi @Cowa. Thanks for opening this issue!

At the moment to use the env_file: docker-compose setting with the plugin the path to the file needs to be fully qualified. For example: env_file: /Users/cowa/project/settings.env

I've updated the README to reflect this. Let me know if making this change enables you to successfully run dockerComposeUp.

That being said, I'm working on removing the need to do this and will let you know when there is a version that doesn't require this modification.

from sbt-docker-compose.

Cowa avatar Cowa commented on September 27, 2024

Thanks @kurtkopchik for the answer.

However my usage is to run tests on a CI (not my machine), so I will not have the qualified path there.
I will wait :)

from sbt-docker-compose.

kurtkopchik avatar kurtkopchik commented on September 27, 2024

Hi @Cowa. I published a 1.0.8-SNAPSHOT release that I believe should fix the issue:
addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.8-SNAPSHOT")

Please let me know if it works for you and if so I'll get an official release out with the change.

from sbt-docker-compose.

Cowa avatar Cowa commented on September 27, 2024

Thanks it works for dockerComposeUp!

But on dockerComposeTest, the .env file seems not to be properly injected.

Play framework cry when loading the configuration:
Could not resolve substitution to a value: ${REDIS_HOST}

But no problem on dockerComposeUp. So it's weird...

from sbt-docker-compose.

tobym avatar tobym commented on September 27, 2024

Hi @Cowa, you could pull in the configuration via a system property myConfigKey = ${redis:6379} which is passed in to the test runner. You can make it optional like this myConfigKey = ${?redis:6379} if you want to attempt setting myConfigKey multiple ways depending on the environment. (See https://github.com/typesafehub/config#optional-system-or-env-variable-overrides).

from sbt-docker-compose.

kurtkopchik avatar kurtkopchik commented on September 27, 2024

It should also be noted that the test cases run by dockerComposeTest run outside of the docker-compose instance. They connect into the instance via the configMap and System property values passed into the test case which contain the dynamically assigned port and container information. From your original compose yml it looks like you are not exposing a port on your Redis service which you will have to do to connect to it from a test case using the info from @tobym

  redis:
    image: iadvize/redis:3
    ports:
      - "6379"
    env_file: .env

Let me know if that works!

from sbt-docker-compose.

Cowa avatar Cowa commented on September 27, 2024

I understand more how it works now, thanks!

There is a problem with the system property though, typesafe/config doesn't allow : so ${redis:6379} is not valid.

I tried with quotes ${"redis:6379"}, but:

Could not resolve substitution to a value: ${"redis:6379"}

(And of course I added the port 6379 for redis)

from sbt-docker-compose.

tobym avatar tobym commented on September 27, 2024

Good catch; yes, you need the quotes. That looks like it should work, however. Could you share the version of Play and typesafe config that you're using, along with the config file?

Also, potentially related: lightbend/config#134

from sbt-docker-compose.

Cowa avatar Cowa commented on September 27, 2024

I use Play 2.5.3 shipped with config 1.3.0.

Config file:

redis {
  host = ${?REDIS_HOST}
  host = ${"redis:6379"}

  port = ${?REDIS_PORT}
  port = 6379

  pool {
    max_connections = 10
    max_connections = ${?REDIS_POOL_MAX_CONNECTIONS}
  }
}

from sbt-docker-compose.

tobym avatar tobym commented on September 27, 2024

Try this:

Shut down sbt, and if there is a file in /tmp/dockerComposeInstances.bin, delete it. (This contains information about running docker-compose instances, and in 1.0.7 there is a bug which may cause the plugin to be unable to find the right instances; this is fixed in the upcoming 1.0.8 release). Run the tests again and see if that fixed it.

from sbt-docker-compose.

tobym avatar tobym commented on September 27, 2024

Here is a trivial app that shows the system property working in isolation of the plugin and docker: https://gist.github.com/tobym/35d0fe799a520122b98e9eebfda266aa

from sbt-docker-compose.

kurtkopchik avatar kurtkopchik commented on September 27, 2024

Cowa I also published and updated version of the 1.0.8-SNAPSHOT release that also includes the fix for the bug mentioned by @tobym.
addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.8-SNAPSHOT")

When you have a moment please sbt update your plugins and give it another try. If it still fails, if we could get the full output from the dockerComposeTest command that would help us track down the root cause.

We are so close....Thanks!

from sbt-docker-compose.

kurtkopchik avatar kurtkopchik commented on September 27, 2024

Excellent! I'm glad you are now up and running with the plugin. I'll let you know when the official release with these changes gets published.

from sbt-docker-compose.

kurtkopchik avatar kurtkopchik commented on September 27, 2024

The official 1.0.8 release has been published: addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.8")

Please open a new issue if you run into any other problems. Thanks again for using the plugin!

from sbt-docker-compose.

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.