4

I recently moved my nodejs application into a docker container. Everything works fine, except static files (e.g. bower components) won't get loaded (404).

Whats wrong?

In my node app:

app.use('/static', express.static(__dirname + '/../public'));

My .bowerrc

{
  "directory": "public/lib"
}

Bower downloads and installs all files in the right directory. I checked it myself inside the docker container.

My dockerfile:

FROM node:4-onbuild
COPY . /src
RUN cd /src/ && npm install && bower install --allow-root
RUN ["node", "/src/server.js"]
EXPOSE 3000
zarathustra
  • 1,898
  • 3
  • 18
  • 38
  • did you resolve it? I have a similar issue: https://stackoverflow.com/questions/57445601/node-serves-empty-static-files-in-a-ssr-when-dockerized – diegosasw Aug 11 '19 at 11:18

1 Answers1

0

Similar problem I faced earlier, This is the problem of bower not docker container, bower doesn't work great with root privileges you need to install all the dependencies with the node install command. Merge Node and Angular dependencies into one package.json and trigger the bower with the node's package.json It might solve your problem.

Vaibhav Jain
  • 2,155
  • 5
  • 27
  • 41