title: Docker - "Error: EACCES: permission denied, mkdir '/project/node_modules/.cache/@babel'"
body: <p>Running <code>yarn docker-build</code> works fine but when <code>yarn docker-up</code> or <code>yarn docker-dev</code> an error pops up when <code>RUN yarn</code> is called. Nginx starts up fine but yarn fails into mkdir in the Projects directory.</p>
  
  <p>package.json</p>
  
  <pre><code>...
      "docker-build": "docker-compose build",
      "docker-dev": "cross-env NGINX_HOST=localhost NGINX_PORT=3000 PORT=3000 docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --no-deps",
      "docker-up": "cross-env NGINX_HOST=localhost NGINX_PORT=80 PORT=8080 docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --no-deps -d",
      "docker-down": "docker-compose down"
  ...
  </code></pre>
  
  <p>Dockerfile</p>
  
  <pre><code>FROM mhart/alpine-node:8
  
  # Install required dependencies (Alpine Linux packages)
  RUN apk update &amp;&amp; \
    apk add --no-cache \
      sudo \
      g++ \
      gcc \
      git \
      libev-dev \
      libevent-dev \
      libuv-dev \
      make \
      openssl-dev \
      perl \
      python
  
  # Add user and make it sudoer
  ARG uid=1000
  ARG user=username
  RUN set -x ; \
    addgroup -g $uid -S $user ; \
    adduser -u $uid -D -S -G $user $user \
    &amp;&amp; exit 0 ; exit 1
  RUN echo $user' ALL=(ALL) NOPASSWD:ALL' &gt;&gt; /etc/sudoers
  
  # Install (global) Yarn packages/dependencies
  RUN yarn global add node-gyp
  RUN git clone --recursive https://github.com/sass/node-sass.git \
    &amp;&amp; cd node-sass \
    &amp;&amp; yarn \
    &amp;&amp; node scripts/build -f
  
  # Make project directory with permissions
  RUN mkdir /project
  
  # Switch to project directory
  WORKDIR /project
  
  # Copy required stuff
  COPY . .
  
  # Give owner rights to the current user
  RUN chown -Rh $user:$user /project
  
  # Install (local) Yarn packages and build
  RUN yarn
  
  USER $user
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>app_1    | [2] Error: EACCES: permission denied, mkdir '/project/node_modules/.cache/@babel'
  app_1    | [2]     at Object.fs.mkdirSync (fs.js:885:18)
  app_1    | [2]     at sync (/project/node_modules/mkdirp/index.js:71:13)
  app_1    | [2]     at sync (/project/node_modules/mkdirp/index.js:77:24)
  app_1    | [2]     at save (/project/node_modules/@babel/register/lib/cache.js:50:20)
  app_1    | [2]     at _combinedTickCallback (internal/process/next_tick.js:132:7)
  app_1    | [2]     at process._tickCallback (internal/process/next_tick.js:181:9)
  app_1    | [2]     at Function.Module.runMain (module.js:696:11)
  app_1    | [2]     at startup (bootstrap_node.js:204:16)
  app_1    | [2]     at bootstrap_node.js:625:3
  </code></pre>
  
  <p>My repo can be found here at <a href="https://github.com/cozy-nyc/cozy-nyc" rel="noreferrer">https://github.com/cozy-nyc/cozy-nyc</a></p>