Friday, 5 May 2017

docker-compose start two node apps

I have structure like this:

├── api
│   ├── server.js
│   ├── Dockerfile
├── docker-compose.yml
└── web
    ├── client
    ├── Dockerfile
    ├── node_modules
    ├── package.json
    └── server

2 Dockerfiles and one docker compose file in root,how can I run both apps with docker compose?

I tried like this:

compose file:

services:
  web:
    build: ./web .
    volumes:
        - .:/app
    ports:
        - "4200:4200"
    restart: always
    command: npm start
   server:
    build ./api .
    volumes:
        - .:/app
    ports:
        - "3100:3100"
    restart: always
    environment:
        - NODE_ENV=production
    command: npm start

Api docker file example:

FROM node:6.9.4

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN npm install nodemon -g

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

EXPOSE 3100

But get error for this part: build: ./web .

Any solution for this?



via Vladimir

No comments:

Post a Comment