我有一个节点项目,该项目在根目录上有一个Web服务器和一个服务。
--myNodeProj
--app.js //the web server
--service.js //an update service
在我的package.json中,我有以下内容:
"scripts": {
"start": "node app.js",
"service": "node service.js"
},
对于我的DockerFile,我有:
FROM node:8
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm install --only=production
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "npm", "start" ]
CMD将运行app.js(网络服务器)。如何使用该服务构建另一个容器?我是否创建另一个Dockerfile? docker build命令看起来会有所不同吗?
答案 0 :(得分:1)
您可以覆盖命令-
<Switch
trackColor={{true: 'red', false: 'grey'}}
onValueChange={this.toggleSwitch}
value={true}/>
答案 1 :(得分:0)
我最终使用了How to customize user profile when using django-allauth。 您需要使用以下代码创建docker-compose.yml文件:
version: '3'
services:
web:
# will build ./docker/web/Dockerfile
build:
context: .
dockerfile: ./docker/web/Dockerfile
ports:
- "3000:3000"
env_file:
- web.env
service:
# will build ./docker/service/Dockerfile
build:
context: .
dockerfile: ./docker/service/Dockerfile
env_file:
- service.env
此文件引用了2个用于构建容器的Dockerfile:
服务
FROM node:8
# Create app directory
WORKDIR /usr/src/service
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm install --only=production
# Bundle app source
COPY . .
CMD [ "node", "service.js" ]
对于网络:
FROM node:8
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm install --only=production
# Bundle app source
COPY . .
#EXPOSE 8080
CMD [ "npm", "start" ]
请注意,我只能开始一个NPM。我直接使用node调用服务。
当我要构建容器时,发出命令:
docker-compose build