Shields: Docker issue: production code imports test dependencies

Created on 27 Jan 2019  Â·  10Comments  Â·  Source: badges/shields

I just did a deploy of the internal Shields instance we host at my day job and ran into a couple dev vs. prod dependency issues. I had to move the below dependencies from dev to prod deps in order to get the container to run:

  • nock
  • icedfrisby
  • icedfrisby-nock
  • caller

Everything worked fine afterwards. I haven't had a chance to dig into the underlying cause yet, but I wouldn't have expected those to be runtime/prod dependencies

blocker self-hosting

Most helpful comment

As an FYI, our internal Shields deployment is now on a weekly schedule to build the latest Docker image and deploy. We definitely still need #2816 but that will provide some marginal help in this space

All 10 comments

Ah… caller is a good clue, since we only import it in one place, which is create-service-tester. After #2809 we import create-service-tester from services/index.js, and that's imported by all the services. Methinks we're going to need to revisit that.

Calls for building some Docker validation sooner rather than later… would have been nice to have caught that earlier in the process (before doing so much work).

That makes sense. Should we close this and track it under #2816 then?

It’s separate from fixing the immediate issue. We could track them separately.

Fair enough. I'm personally working around this by running an npm uninstall --save-dev and than npm i --save on those 4 dependencies in my build process prior to building the Docker image.

I'm assuming we want reconsider whether create-service-tester gets imported which sounds like a bigger fix vs. doing a short term fix by adding those 4 deps as prod dependencies?

If anyone else is having problems running the image we could point them here to run those two npm commands prior to the docker build ... command.

Another workaround is to use the commit before that one, temporarily.

I don’t think we should make these prod dependencies. I don’t think it needs to take a long time to fix the problem.

Sounds good (and agreed)

Thoughts on how to fix this?

I’m reluctant to add more magic here, like conditional imports or try/catch imports. How about moving the test shortcut imports from services/index.js to services/tester.js, and updating all the tester imports to reference that instead?

I like that idea. I'll take a shot at it later this week

Just adding a note that ServiceTester which is also imported in services/index.js also imports some dev deps (icedfrisby and icedfrisby-nock) so I'm going to move both ServiceTester and create-service-tester from services/index.js to services/tester.js

As an FYI, our internal Shields deployment is now on a weekly schedule to build the latest Docker image and deploy. We definitely still need #2816 but that will provide some marginal help in this space

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niccokunzmann picture niccokunzmann  Â·  3Comments

lukeeey picture lukeeey  Â·  3Comments

Turnerj picture Turnerj  Â·  3Comments

najeeb-ur-rehman picture najeeb-ur-rehman  Â·  3Comments

salaros picture salaros  Â·  3Comments