nesalexy
nesalexy

Reputation: 878

Docker config angular project

Sorry for my english. I new docker and for me now it not easy. I want configurate this project:

Then i added two files

enter image description here

my docker-compose

web:
    build: .
    ports:
        - '49153:49153'
    volumes:
        - .:/usr/src/app/
    environment:
        - NODE_ENV=dev
    command: bash -c "npm start"

Dockerfile

FROM node:8.6 as node

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm install
RUN npm install -g angular-cli
COPY . /usr/src/app

EXPOSE 49153

CMD [ "npm", "start" ]

Then i run like this:

docker-compose build

and

docker-compose up

My question: haw i correct write settings to Docker? In console when i do docker-compose build message

gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.6.0' ]
gyp verb install input version string "8.6.0"
gyp verb install installing version: 8.6.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.6.0
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp/8.6.0
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp/8.6.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp"

Upvotes: 0

Views: 220

Answers (1)

Sujay Pillai
Sujay Pillai

Reputation: 433

Before getting on to answer your question:

  1. You don't need "angular-cli" dependency in your app package for it to run. So you should remove it from Dockerfile.
  2. Add a .dockerignore file and add the below line in it -

    node_modules

    npm-debug.log

    This will prevent your local modules and debug logs from being copied onto your Docker image and possibly overwriting modules installed within your image.

I see you trying to use multi-stage build in your Dockerfile with just one stage in it. The below is screenshot of my Dockerfile for the angular quickstart sample enter image description here

Upvotes: 1

Related Questions