dockerfile-node icon indicating copy to clipboard operation
dockerfile-node copied to clipboard

Support adding instructions at the start of the stage

Open nahtnam opened this issue 1 year ago • 3 comments
trafficstars

Use case: I'd like to add certain files before running the build or install.

nahtnam avatar Jan 03 '24 01:01 nahtnam

I have an analogous feature in dockerfile-rails: https://github.com/fly-apps/dockerfile-rails#advanced-customization (`--instructions), which would be relatively straightforward to port to this package.

More precise feedback on where exactly the instructions would be placed would be helpful. You can look at the dockerfile rails template to get an idea of what is implemented there:

  • base is added to the end of the base step
  • build is added just after the COPY . . statement
  • deploy is added just after the COPY --from-build statement (and the rails user is created, which does not currently apply in dockerfile-node).

Would this work for you?

rubys avatar Jan 03 '24 03:01 rubys

Hmm so this use case was copying the .yarn folder (contains plugins) which needs to be copied before the yarn install command. I ended up ejecting because it was a bit too hard to maintain and also we went with Next.js's "standalone mode"

nahtnam avatar Jan 04 '24 06:01 nahtnam

That use case seems common enough that it shouldn't require additional instructions. See this from dockerfile-rails:

https://github.com/fly-apps/dockerfile-rails/blob/b348b6962b928f64803ce0c3260c6eb98f5a8cb0/lib/generators/templates/_npm_install.erb#L3-L5

I assume that you have a .yarnrc? And what directories should be copied from the .yarn directory?

rubys avatar Jan 04 '24 21:01 rubys