2017-05-05 127 views
0

我有結構是這樣的:搬運工,撰寫啓動兩個節點應用

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

2個Dockerfiles和根系泊塢窗一個文件的撰寫,我怎麼可以運行與碼頭工人這兩個應用組成?

我想是這樣的:

撰寫文件:

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 

阿比泊塢窗文件例如:

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 

但得到錯誤的這一部分:build: ./web .

所有解決方案這個?

+0

刪除最後一個點('.')並嘗試 –

回答

0

你的生產線上有一個額外的點。期間通常是指示上下文的當前目錄,但您只需將其更改爲目錄,而不是添加額外的部分。你的服務器上還有一個間距問題,yaml文件對空白敏感。最後,請確保包含版本行:

version: '2' 
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