testcontainers / testcontainers-hs

Docker containers for your integration tests! http://hackage.haskell.org/package/testcontainers
MIT License
56 stars 12 forks source link

Tagging `fromBuildContext` images #14

Closed tapegram closed 2 years ago

tapegram commented 2 years ago

Let me know if this is an anti pattern but I am trying to build my application image via TestContainers and then hit the running container with http requests to integration test it. To build the image and run the container im doing something like this

containers1
  :: MonadDocker m => m ()
containers1 = do
  image <- build $ fromBuildContext "." (Just "Dockerfile")
  _ <- run $ containerRequest image & setExpose [ 8080 ]
  pure ()

and I get this error

uncaught exception: DockerException
        DockerException {exitCode = ExitFailure 125, args = ["run","--detach","--publish","8080","--rm",""], stderr = "docker: invalid reference format.\nSee 'docker run --help'.\n"}

I'm pretty sure this is because when I build the image locally like this, it's not tagging the image at all and it ends up empty as the last run arg.

Would it make sense to support being able to tag images created this way? Or is this an antipattern?

alexbiehl commented 2 years ago

@tapegram The problem you described sounds like a bug to me!

I believe we need to pass

--quiet , -q |   | Suppress the build output and print image ID on success

when invoking Docker. We are doing the right thing for fromTag and fromDockerfile already!

alexbiehl commented 2 years ago

I pushed the fix https://github.com/alexbiehl/testcontainers-hs/commit/8c4d8e5fdc6e5cfe6a8c80706f5586c4a80a36d9 to master.

tapegram commented 2 years ago

Such quick turnaround! Thank you very much!

tapegram commented 2 years ago

Would it also be possible to do another release (or tag) in the near future? Would like to incorporate the fix in my current project. Thanks! Very excited to use test containers in haskell for my CI pipeline!

alexbiehl commented 2 years ago

Argl, sorry for being so slow. Yes, I will cut a new release ASAP.

alexbiehl commented 2 years ago

I released testcontainers-0.3.1.0.