0

I want to be able to build images for testing purpose without publishing the changes I made in any of my packages to npm

Here is the structure of the folders:

/backend
  /server
    DockerFile
    package.json
  /http
    package.json
  /api
    package.json
  /dashboard
    DockerFile
    package.json 

So each folder is a npm package (and a git repository). Here are the links between these npm packages:

  • /server requires /http
  • /http requires /api
  • /dashboard requires /api

When I develop locally I use npm link, but when I want to build the docker images of /server and /dashboard, the npm links are no longer used and the packages are pulled from the published versions hosted on npm during the npm install in the container.

How can I build images based on the changes I made locally ?

I tried to link packages using a relative path in package.json : "my-http": "file:./../http" instead of "my-http": "0.1.0"

It works locally but it's out of context when I try to build this in docker

Raphaël
  • 1
  • 1
  • 2
    You need to use the top-level `backend` directory as the build context (the directory option to `docker build` or Compose `build:`) and then `COPY` this entire source tree in for the relative links to work. Also see [How to include files outside of Docker's build context?](https://stackoverflow.com/questions/27068596/how-to-include-files-outside-of-dockers-build-context); at least one answer has a specific Typescript example. – David Maze Mar 16 '22 at 11:15

0 Answers0