ether / etherpad-lite

Etherpad: A modern really-real-time collaborative document editor.
http://docs.etherpad.org/
Apache License 2.0
16.46k stars 2.84k forks source link

Package.json is missing for local plugin #6562

Open ZigzagSecurity opened 1 month ago

ZigzagSecurity commented 1 month ago

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):

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 !

SamTV12345 commented 1 month ago

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

JannikStreek commented 1 month ago

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.

SamTV12345 commented 1 month ago

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 :)

JannikStreek commented 2 weeks ago

@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 commented 2 weeks ago

@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.

ZigzagSecurity commented 1 week ago

@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"