Tuesday, 30 May 2017

Can't require image in docker build

I'm trying to dockerize a node/react app. In the JSX (./src/containers/Header/index.js) I require an image, like so:

<Link to={'/'}>
  <img src={require("./assets/cd-logo.jpg")} alt="Logo" role="presentation" />
</Link>

When Docker runs the client build script I get an error:

ERROR in ./src/containers/Header/assets/cd-logo.jpg
Module build failed: Error: /code/node_modules/mozjpeg/vendor/cjpeg: 1:
/code/node_modules/mozjpeg/vendor/cjpeg: Syntax error: 
word unexpected (expecting ")")

    at Promise.all.then.arr (/code/node_modules/execa/index.js:201:11)
    at process._tickCallback (internal/process/next_tick.js:103:7)
 @ ./src/containers/Header/index.js 53:48-79
 @ ./src/containers/Home/index.js
 @ ./src/routes.js
 @ ./src/containers/App/index.js
 @ ./src/client.js
error Command failed with exit code 2.
error Command failed with exit code 1.

Dockerfile:

FROM node:7.1.0

RUN mkdir -p /code
WORKDIR /code
COPY . /code
RUN npm install -g -s --no-progress yarn && \
    yarn && \
    npm rebuild node-sass --force
CMD [ "npm", "run", "start:production" ]
EXPOSE 8080

Can anyone shed any light? (Repo here)



via user1775718

No comments:

Post a Comment