redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Unable to preview-docs from Docker

Open PeeZu opened this issue 5 years ago • 3 comments

Describe the bug I would like to use the Docker container to preview the documentation instead of using directly npx

To Reproduce Steps to reproduce the behavior:

  1. Assuming you have a valid openapi.yaml in the same directory
  2. Run this command: docker container run -t --rm -v ${PWD}:/spec -p 8080:8080 redocly/openapi-cli preview-docs /spec/openapi.yaml
  3. See error

Expected behavior The Docker container exposing the preview documention

Logs

TypeError: o is not a constructor
    at Object.t.startWsServer (/bin/openapi-cli:43:129218)
    at Object.<anonymous> (/bin/openapi-cli:43:21717)
    at Generator.next (<anonymous>)
    at s (/bin/openapi-cli:43:19069)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)

openapi-cli Version(s) 1.0.0-beta.40

Node.js Version(s) v15.12.0

Additional context Using the provided Dockerfile in this repo, works as expected outside Docker

PeeZu avatar Apr 01 '21 14:04 PeeZu

This bug is likely introduced in PR #177.

The /bin/openapi-cli file in the Dockerfile is compiled by Webpack https://github.com/Redocly/openapi-cli/blob/360c865d23668c46cad9ee63677fce54925ce238/Dockerfile#L10-L15

However, the simple-websocket is configured to be null-loaded https://github.com/Redocly/openapi-cli/blob/360c865d23668c46cad9ee63677fce54925ce238/webpack.config.ts#L20-L30

Therefore, the SocketServer will become {} when compiled by Webpack, hence the error TypeError: o is not a constructor. https://github.com/Redocly/openapi-cli/blob/360c865d23668c46cad9ee63677fce54925ce238/packages/cli/src/commands/preview-docs/preview-server/server.ts#L5 https://github.com/Redocly/openapi-cli/blob/360c865d23668c46cad9ee63677fce54925ce238/packages/cli/src/commands/preview-docs/preview-server/server.ts#L65-L66

Pinging @RomanHotsiy and @knidarkness to raise awareness of this issue.

Juneezee avatar Sep 07 '21 12:09 Juneezee

Fixed in #364 (merged into master in commit 128aea923bf03437945f29392cd3cd2e94963d59)

Juneezee avatar Sep 15 '21 05:09 Juneezee

Great job guys !

PeeZu avatar Sep 16 '21 10:09 PeeZu