title: Dockerfile with nextjs and puppteer permission denied
body: <p>I've been struggling for months on this. I don't understand why I run into this permission issues. I'm on Centos7 and it works on my local machine, but when I try and deploy to server I get this error.</p>
  <pre><code>FROM node:12-slim
  
  # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
  # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
  # installs, work.
  RUN apt-get update \
      &amp;&amp; apt-get install -y wget gnupg \
      &amp;&amp; wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
      &amp;&amp; sh -c 'echo &quot;deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main&quot; &gt;&gt; /etc/apt/sources.list.d/google.list' \
      &amp;&amp; apt-get update \
      &amp;&amp; apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
        --no-install-recommends \
      &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  # If running Docker &gt;= 1.13.0 use docker run's --init arg to reap zombie processes, otherwise
  # uncomment the following lines to have `dumb-init` as PID 1
  # ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
  # RUN chmod +x /usr/local/bin/dumb-init
  # ENTRYPOINT [&quot;dumb-init&quot;, &quot;--&quot;]
  
  # Uncomment to skip the chromium download when installing puppeteer. If you do,
  # you'll need to launch puppeteer with:
  #     browser.launch({executablePath: 'google-chrome-stable'})
  # ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
  
  # Install puppeteer so it's available in the container.
  RUN npm i puppeteer \
      # Add user so we don't need --no-sandbox.
      # same layer as npm install to keep re-chowned files from using up several hundred MBs more space
  #    &amp;&amp; groupadd -r node &amp;&amp; useradd -r -g node -G audio,video node \
          &amp;&amp; mkdir -p /home/node/Downloads \
          &amp;&amp; mkdir -p /home/node/.next/static \
          &amp;&amp; mkdir -p /home/node/node_modules \
     &amp;&amp; mkdir -p /home/node/node_modules  \
      &amp;&amp; chown -R node:node /home/node \
      &amp;&amp; chown -R node:node /node_modules \
          &amp;&amp; chown -R node:node /home/node \
          &amp;&amp; chown -R node:node /home/node/.next/static \
          &amp;&amp; chmod -R 777 /home/node/.next
  
  
  # Run everything after as non-privileged user.
  
  
  #RUN mkdir -p /home/node/app
  RUN chown -Rh $user:$user /home/node
  RUN $user
  RUN npm config set unsafe-perm true
  #RUN yarn install -g --unsafe-perm next
  RUN ls -la /home/node/.next/static
  
  WORKDIR /home/node
  
  COPY . .
  USER node
  
  RUN yarn install  &amp;&amp; yarn run build
  
  EXPOSE 7000
  
  CMD [&quot;yarn&quot;, &quot;run&quot;, &quot;start&quot;]
  </code></pre>
  <p>on docker-compose build; docker-compose up we the following issue. I've tried npm and arn.</p>
  <pre><code>$ next build
  info  - Creating an optimized production build...
  
  &gt; Build error occurred
  Error: EACCES: permission denied, open '/home/node/.next/cache/config.json.1544779693'
      
  error Command failed with exit code 1.
  </code></pre>
  <p>What do I need to do to get this to run?</p>