Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Permissions error using EC2 linux intel instance #222

Open
Cally99 opened this issue Oct 21, 2021 · 1 comment
Open

Permissions error using EC2 linux intel instance #222

Cally99 opened this issue Oct 21, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@Cally99
Copy link

Cally99 commented Oct 21, 2021

Versions

"nuxt-vite": "^0.1.1",
"nuxt": "2.15.7"

I'm using docker compose to build my app and deploy to an EC2 instance.
In dev mode and using nuxt start everything works fine on my local machine which is mac.

I wasn't using vite before and due to the slow build times over and over again deploying code changes to reproduction I decided to give vite a go. It's very quick on my local machine compared to before.

Unfortunately I can't figure out how to set permission access to '/app/node_modules/.cache/vite/client'

I've tried numerous solutions online but no luck.

Here's my setup

docker-compose-prod.yaml

  frontend:
    build:
      context: ./frontend
      dockerfile: docker/Dockerfile.dev
    volumes:
      - "./frontend:/app/"
      - "node_modules:/app/node_modules"

    ports:
      - "3000:3000"
      - "24678:24678"
    environment:
      - API_URI=http://backend:8000/api
    networks:
      - main

Dockerfile.prod

FROM node:14.15.5

# make the 'app' folder the current working directory
WORKDIR /app/

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . /app/
RUN mkdir - p node_modules / .cache && chmod - R 777 node_modules / .cache
RUN npm i -g npm@latest

RUN npm config set unsafe - perm true
RUN npm config set save-prefix=''

# If building from scratch unhighlight the below.
RUN npm install --prefer-offline --no-audit
RUN npm rebuild node-sass

RUN npm rebuild esbuild
#Set environment variables
ENV SENTRY_DISABLED=true
ENV HOST 0.0.0.0

# expose port 3000 to the host
EXPOSE 3000

ENTRYPOINT ["sh","docker/start_prod.sh"]

start_prod.sh

#!/bin/bash
# run the production server
npm run build
npm run start

docker-compose build works fine. It's when you try docker-compose up and nuxt is generating a error occurs for permissions in the cache

Has anyone experienced this issue before or have a working example on ec2?

nuxt config

  buildModules: [
    'nuxt-vite'
  ],
  vite: {
    build: true
  },
  server: {
    hmr: {
      protocol: 'ws',
      host: 'localhost'
    }
  },
frontend_1  | 2021-10-21T23:24:46.623400474Z 🧪  Vite mode is experimental and some nuxt modules might be incompatible
frontend_1  | 2021-10-21T23:24:46.623458914Z     If found a bug, please report via https://github.com/nuxt/vite/issues with a minimal reproduction.
frontend_1  | 2021-10-21T23:24:46.623553202Z     You can enable unstable server-side rendering using `vite: { ssr: true }` in `nuxt.config`
frontend_1  | 2021-10-21T23:24:46.692114471Z ℹ [HPM] Proxy created: /api/  -> https://127.0.0.1/
frontend_1  | 2021-10-21T23:24:46.693352393Z ℹ [HPM] Proxy rewrite rule created: "^/api/" ~> ""
frontend_1  | 2021-10-21T23:24:48.222804468Z ℹ [HPM] Proxy created: /  ->  http://backend:8000/api
frontend_1  | 2021-10-21T23:24:48.227370360Z [HPM] Subscribed to http-proxy events:  [ 'proxyReq', 'proxyRes', 'error', 'close' ]
frontend_1  | 2021-10-21T23:24:48.238357245Z ℹ Listening on: http://172.23.0.2:3000/
frontend_1  | 2021-10-21T23:24:49.607924830Z ℹ Preparing project for development
frontend_1  | 2021-10-21T23:24:49.608970487Z ℹ Initial build may take a while
frontend_1  | 2021-10-21T23:24:49.613330351Z ✔ Builder initialized
frontend_1  | 2021-10-21T23:24:50.008526512Z ✔ Nuxt files generated
frontend_1  | 2021-10-21T23:24:51.550504406Z 
frontend_1  | 2021-10-21T23:24:51.550597730Z  ERROR  EACCES: permission denied, mkdir '/app/node_modules/.cache/vite/client'
frontend_1  | 2021-10-21T23:24:51.550683306Z 
frontend_1  | 2021-10-21T23:24:51.550699441Z   at Object.mkdirSync (fs.js:987:3)
frontend_1  | 2021-10-21T23:24:51.550732945Z   at optimizeDeps (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73133:21)
frontend_1  | 2021-10-21T23:24:51.550767255Z   at runOptimize (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73827:54)
frontend_1  | 2021-10-21T23:24:51.550810294Z   at Object.createServer (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73860:15)
frontend_1  | 2021-10-21T23:24:51.550824945Z   at async buildClient (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:106:22)
frontend_1  | 2021-10-21T23:24:51.550861657Z   at async bundle (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:459:3)
frontend_1  | 2021-10-21T23:24:51.550892919Z   at async Builder.build (node_modules/@nuxt/builder/dist/builder.js:327:5)
frontend_1  | 2021-10-21T23:24:51.550949081Z   at async Object._buildDev (node_modules/@nuxt/cli/dist/cli-dev.js:107:5)
frontend_1  | 2021-10-21T23:24:51.550965014Z   at async Object.startDev (node_modules/@nuxt/cli/dist/cli-dev.js:65:7)
frontend_1  | 2021-10-21T23:24:51.550998246Z   at async Object.run (node_modules/@nuxt/cli/dist/cli-dev.js:52:5)
frontend_1  | 2021-10-21T23:24:51.551011919Z   at async NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:413:7)
frontend_1  | 2021-10-21T23:24:51.551043335Z 


@Cally99 Cally99 added the bug Something isn't working label Oct 21, 2021
@Cally99
Copy link
Author

Cally99 commented Oct 26, 2021

Bumping. Can anyone show a working version using docker in production mode?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant