I have a simple ReactJS application, which is deployed to AWS EB, with Docker.
My Dockerfile looks like this:
FROM node:12.2.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
ENV REACT_APP_VAR val
ENV REACT_APP_VAR2 val2
COPY package.json /app/package.json
RUN npm install --silent --unsafe-perm --max-old-space-size=1024
RUN npm install react-scripts@3.0.1 -g --silent --max-old-space-size=1024
COPY . /app
RUN npm --max-old-space-size=1024 run build
FROM nginx:1.16.0-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
I have been using the same docker file for months by now. Today suddenly, I start build errors like below on AWS EB Logs (and got the same error while trying to build the image on my local)
Step 21/26 : RUN npm --max-old-space-size=1024 run build
---> Running in 879c536e7f65
> frontend@0.1.0 build /app
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/components/file.js
Line 187:5: 'SomeCustomButtonRef' is not defined no-undef
Search for the keywords to learn more about each error.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-02-23T10_25_14_373Z-debug.log
This error started happening today, out of sudden.
When I run the command npm --max-old-space-size=1024 run build
on my local w/o any Docker related commands, it runs fine and builds.
I have tried to change the node version tag in Dockerfile, but the result was the same. I have tried to comment out the part where it breaks (it is simply SomeCustomButtonRef = React.createRef()
) but then docker build command breaks with more lines ABC is not defined no-undef
in some other file.
Any one had similar issue with react + docker, especially like out of sudden it starts breaking the builds ?