I'm trying to deploy a Create React App webapp on OpenShift using a Dockerfile. The OpenShift build completes successfully and when I visit the route I'm able to see the application running for 1 second and then this error comes on the screen:
Failed to compile
EACCES: permission denied, open '/home/node/app/.eslintcache'
I don't understand why the permission denied error is coming because I've assigned the directory permissions needed to the node
user provided by the node Docker image in my Dockerfile.
Here's my Dockerfile:
FROM node:14-alpine
RUN mkdir -p /home/node/app &&\
chmod -R 775 /home/node/app &&\
chown -R node:node /home/node/app
WORKDIR /home/node/app
COPY package*.json /home/node/app/
USER node
RUN npm install
COPY --chown=node:node . /home/node/app
EXPOSE 3000
CMD ["npm", "start"]
Software versions:
react-scripts 4.0.1
OpenShift 4.2, 4.4, 4.5 (Tried with all)
Here's the tutorial I used as reference and the source repo.
Update:
Thanks to Will Gordon's answer, I was able to figure it out. OpenShift expects you to specify the user ID and not the name. Also, OpenShift runs containers as a random ID belonging to group 0 so permission for that group needs to be specified. Here's the working Dockerfile:
FROM node:14-alpine
RUN mkdir -p /home/node/app &&\
chown -R node:node /home/node/app
WORKDIR /home/node/app
RUN chgrp -R 0 /home/node/app &&\
chmod -R g+rwX /home/node/app
COPY package*.json /home/node/app/
USER 1000
RUN npm install
COPY --chown=node:node . /home/node/app
EXPOSE 3000
CMD ["npm", "start"]
WORKDIR /home/node/app
is for? My Dockerfile is very similar to the solution in this question. Further, the Dockerfile gives no errors at build so I'm assuming the permissions are fine. It's the new.eslintcache
file that latestreact-scripts
versions have started to create is what's causing the problem. – Elicia