osrm-frontend icon indicating copy to clipboard operation
osrm-frontend copied to clipboard

Errors when using the latest Dockerimage

Open Redy1908 opened this issue 1 year ago • 1 comments

When using an image constructed with the following Dokcerfile:

FROM ghcr.io/project-osrm/osrm-frontend:latest

EXPOSE 9966

CMD ["npm", "start"]

I get the following 2 errors:

  1. 2024-04-12 14:07:23 /src/node_modules/budo/node_modules/micromatch/index.js:44
    2024-04-12 14:07:23     let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
    2024-04-12 14:07:23                                                    ^^^
    2024-04-12 14:07:23 SyntaxError: Unexpected token ...
    2024-04-12 14:07:23     at Object.exports.runInThisContext (vm.js:76:16)
    2024-04-12 14:07:23     at Module._compile (module.js:542:28)
    2024-04-12 14:07:23     at Object.Module._extensions..js (module.js:579:10)
    2024-04-12 14:07:23     at Module.load (module.js:487:32)
    2024-04-12 14:07:23     at tryModuleLoad (module.js:446:12)
    2024-04-12 14:07:23     at Function.Module._load (module.js:438:3)
    2024-04-12 14:07:23     at Module.require (module.js:497:17)
    2024-04-12 14:07:23     at require (internal/module.js:20:19)
    2024-04-12 14:07:23     at Object.<anonymous> (/src/node_modules/budo/lib/budo.js:6:15)
    2024-04-12 14:07:23     at Module._compile (module.js:570:32)
    
  2. 2024-04-12 14:16:43 Error: Parsing file /src/src/leaflet_options.js: Unexpected token (57:12)
    2024-04-12 14:16:43     at Deps.parseDeps (/src/node_modules/module-deps/index.js:519:15)
    2024-04-12 14:16:43     at getDeps (/src/node_modules/module-deps/index.js:447:44)
    2024-04-12 14:16:43     at /src/node_modules/module-deps/index.js:430:38
    2024-04-12 14:16:43     at ConcatStream.<anonymous> (/src/node_modules/concat-stream/index.js:37:43)
    2024-04-12 14:16:43     at emitNone (events.js:91:20)
    2024-04-12 14:16:43     at ConcatStream.emit (events.js:185:7)
    2024-04-12 14:16:43     at finishMaybe (/src/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:630:14)
    2024-04-12 14:16:43     at endWritable (/src/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:638:3)
    2024-04-12 14:16:43     at ConcatStream.Writable.end (/src/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:594:22)
    2024-04-12 14:16:43     at DuplexWrapper.onend (/src/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    

The second error can be fixed by modifying the malformed URL within /src/src/leaflet_options.js inside the container (line 57):

  services: [{
    label: 'Car (fastest)',
    path: ''http://localhost:5000'/route/v1'  // -> replace with 'http://localhost:5000/route/v1'
  }],

However, I am unable to resolve the first error. Any insights would be greatly appreciated. Additionally, it is quite peculiar that the second error was not flagged earlier.

Redy1908 avatar Apr 12 '24 12:04 Redy1908

I came across the same problem, except using podman, with the command, podman run -p 9966:9966 ghcr.io/project-osrm/osrm-frontend:latest.

I suspect the problem is related to the fact the Dockerfile for the container is still using alpine 3.5, (the oldest version the package website is currently showing is v.12 and that is nodejs 12.22 the current package manger.

Looking at the version of nodejs from a mirror alpine 3.5 has at most nodejs 6.9.5 (it had access to 7.2.1 via nodejs-current instead).

As such it would seem it most likely was broken in by #370 when budo was upgraded from 9.4.0 to 11.8.4.

donno avatar Aug 02 '24 13:08 donno

quick solution for error one:

FROM node:8.17.0-alpine

WORKDIR /

# Install git and other necessary tools using apk
RUN apk update && \
    apk add --no-cache git && \
    git clone --depth 1 https://github.com/Project-OSRM/osrm-frontend.git && \
    cd /osrm-frontend && \
    npm install && \
    # Remove git after use to reduce image size
    apk del git

WORKDIR /osrm-frontend

EXPOSE 9966

CMD ["npm", "start"]

semarche-kaltura avatar Nov 14 '24 13:11 semarche-kaltura

Fixed by #383

frodrigo avatar Mar 01 '25 21:03 frodrigo