etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

Package.json is missing for local plugin

Open ZigzagSecurity opened this issue 1 year ago • 5 comments

Describe the bug Hi ! I've been trying to create a custom docker image including some plugins but i'm running into some issues concerning local plugins. The image builds successfully if i specify only plugins from NPM registry but as soon as i include a local plugin it fails to find the "package.json" file and exit the build with an error.

To Reproduce Steps to reproduce the behavior:

  1. Follow the instruction from github repo to create a custom docker image.
  2. Modify the Dockerfile as follow (just adding a local plugin): ARG ETHERPAD_LOCAL_PLUGINS="../ep_markdown"
  3. Start the build process with: sudo docker build . -t tmp/etherpad
  4. Then get the error with the local plugin

Expected behavior The build should complete successfully and the local plugin should be installed.

Screenshots The only modification of the Dockerfile: image

The error during the build: image

Server (please complete the following information):

  • Etherpad version: 2.1.1
  • OS:
  • Node.js version (node --version): node:alpine from docker
  • npm version (npm --version): 9.0.4
  • Is the server free of plugins: yes

Additional context I've tried with plugins i've modified myself but also with plugins i've downloaded from npm and put in my local system but the result is the same.

Thanks for reading and your amazing work on Etherpad !

ZigzagSecurity avatar Aug 06 '24 08:08 ZigzagSecurity

Describe the bug Hi ! I've been trying to create a custom docker image including some plugins but i'm running into some issues concerning local plugins. The image builds successfully if i specify only plugins from NPM registry but as soon as i include a local plugin it fails to find the "package.json" file and exit the build with an error.

To Reproduce Steps to reproduce the behavior:

  1. Follow the instruction from github repo to create a custom docker image.
  2. Modify the Dockerfile as follow (just adding a local plugin): ARG ETHERPAD_LOCAL_PLUGINS="../ep_markdown"
  3. Start the build process with: sudo docker build . -t tmp/etherpad
  4. Then get the error with the local plugin

Expected behavior The build should complete successfully and the local plugin should be installed.

Screenshots The only modification of the Dockerfile: image

The error during the build: image

Server (please complete the following information):

  • Etherpad version: 2.1.1
  • OS:
  • Node.js version (node --version): node:alpine from docker
  • npm version (npm --version): 9.0.4
  • Is the server free of plugins: yes

Additional context I've tried with plugins i've modified myself but also with plugins i've downloaded from npm and put in my local system but the result is the same.

Thanks for reading and your amazing work on Etherpad !

Hi I had a look at it. It's actually pretty hard to integrate a plugin into the Docker Image. We have the problem that we build now everything in the Dockerfile and Docker does not have access to the host system. @JannikStreek do you have time to take the matter into your hand? I'm not really familiar with the new Docker directives maybe you can there map a local volume

SamTV12345 avatar Aug 06 '24 18:08 SamTV12345

Describe the bug Hi ! I've been trying to create a custom docker image including some plugins but i'm running into some issues concerning local plugins. The image builds successfully if i specify only plugins from NPM registry but as soon as i include a local plugin it fails to find the "package.json" file and exit the build with an error. To Reproduce Steps to reproduce the behavior:

  1. Follow the instruction from github repo to create a custom docker image.
  2. Modify the Dockerfile as follow (just adding a local plugin): ARG ETHERPAD_LOCAL_PLUGINS="../ep_markdown"
  3. Start the build process with: sudo docker build . -t tmp/etherpad
  4. Then get the error with the local plugin

Expected behavior The build should complete successfully and the local plugin should be installed. Screenshots The only modification of the Dockerfile: image The error during the build: image Server (please complete the following information):

  • Etherpad version: 2.1.1
  • OS:
  • Node.js version (node --version): node:alpine from docker
  • npm version (npm --version): 9.0.4
  • Is the server free of plugins: yes

Additional context I've tried with plugins i've modified myself but also with plugins i've downloaded from npm and put in my local system but the result is the same. Thanks for reading and your amazing work on Etherpad !

Hi I had a look at it. It's actually pretty hard to integrate a plugin into the Docker Image. We have the problem that we build now everything in the Dockerfile and Docker does not have access to the host system. @JannikStreek do you have time to take the matter into your hand? I'm not really familiar with the new Docker directives maybe you can there map a local volume

I can have a look at it. On first glance, the given plugins are indeed currently not copied into the container so it can't really work.

JannikStreek avatar Aug 07 '24 05:08 JannikStreek

Describe the bug Hi ! I've been trying to create a custom docker image including some plugins but i'm running into some issues concerning local plugins. The image builds successfully if i specify only plugins from NPM registry but as soon as i include a local plugin it fails to find the "package.json" file and exit the build with an error. To Reproduce Steps to reproduce the behavior:

  1. Follow the instruction from github repo to create a custom docker image.
  2. Modify the Dockerfile as follow (just adding a local plugin): ARG ETHERPAD_LOCAL_PLUGINS="../ep_markdown"
  3. Start the build process with: sudo docker build . -t tmp/etherpad
  4. Then get the error with the local plugin

Expected behavior The build should complete successfully and the local plugin should be installed. Screenshots The only modification of the Dockerfile: image The error during the build: image Server (please complete the following information):

  • Etherpad version: 2.1.1
  • OS:
  • Node.js version (node --version): node:alpine from docker
  • npm version (npm --version): 9.0.4
  • Is the server free of plugins: yes

Additional context I've tried with plugins i've modified myself but also with plugins i've downloaded from npm and put in my local system but the result is the same. Thanks for reading and your amazing work on Etherpad !

Hi I had a look at it. It's actually pretty hard to integrate a plugin into the Docker Image. We have the problem that we build now everything in the Dockerfile and Docker does not have access to the host system. @JannikStreek do you have time to take the matter into your hand? I'm not really familiar with the new Docker directives maybe you can there map a local volume

I can have a look at it. On first glance, the given plugins are indeed currently not copied into the container so it can't really work.

Thanks for the help :)

SamTV12345 avatar Aug 11 '24 18:08 SamTV12345

@ZigzagSecurity I think the easiest way (which doesn't need any changes in the code base ) would be to mount your local files (e.g. in the docker compose volume section). Lets take the example of "../ep_markdown":

    volumes:
      - ../ep_markdown:/opt/ep_markdown
      

You can also mount without using docker compose, but its easier to demonstrate it in this case.

With that it should work 🤔 Can you test it?

JannikStreek avatar Aug 23 '24 11:08 JannikStreek

@ZigzagSecurity I think the easiest way (which doesn't need any changes in the code base ) would be to mount your local files (e.g. in the docker compose volume section). Lets take the example of "../ep_markdown":

    volumes:
      - ../ep_markdown:/opt/ep_markdown
      

You can also mount without using docker compose, but its easier to demonstrate it in this case.

With that it should work 🤔 Can you test it?

Ah sorry, my bad, that won't work as the mount is too late. Can you add this to your docker file before the install command (RUN bin/installDeps.sh) is reached in the Dockerfile and see if it works:

COPY --chown=etherpad:etherpad ../ep_markdown ../ep_markdown/

Otherwise I will test myself later. We should modify the docker file to copy all plugins given in ETHERPAD_LOCAL_PLUGINS to the container during build time before the install command is called.

JannikStreek avatar Aug 23 '24 11:08 JannikStreek

@JannikStreek i tried it but went into the same issue as reported in the first place. The instruction you specified did not work as the folder is out of the Docker context and thus can't be reach during the build (from what i could understand after a quick google search). image

I changed it to:

COPY --chown=etherpad:etherpad ./ep_markdown ./ep_markdown/

The plugins seems to be copied to the docker but then an error happens when the dependencies are being installed. image

image i also changed the argument for local plugin accordingly:

ARG ETHERPAD_LOCAL_PLUGINS="./ep_markdown"

ZigzagSecurity avatar Aug 30 '24 13:08 ZigzagSecurity

@JannikStreek i tried it but went into the same issue as reported in the first place. The instruction you specified did not work as the folder is out of the Docker context and thus can't be reach during the build (from what i could understand after a quick google search). image

I changed it to:

COPY --chown=etherpad:etherpad ./ep_markdown ./ep_markdown/

The plugins seems to be copied to the docker but then an error happens when the dependencies are being installed. image

image i also changed the argument for local plugin accordingly:

ARG ETHERPAD_LOCAL_PLUGINS="./ep_markdown"

Yes that should be the solution. It's unfortunate that you can't mount directories at build time. Maybe this will come at some time.

SamTV12345 avatar Sep 15 '24 09:09 SamTV12345