Docker搭建Rap2接口文档

一、创建磁盘目录下载git项目

git clone https://github.com/thx/rap2-delos.git

二、切换到当前目录下通过docker-compose的方式启动

docker-compose up -d 

三、初始化容器环境

进入容器:docker exec -it rap2-delos sh

初始化node:node scripts/init

退出容器:exit

t停止容器:docker-compose down

容器后台运行:docker-compose up -d

四、测试安装是否完成:curl localhost:38080输入hello-rap表示安装成功

五、创建另一个磁盘目录下载项目

git clone https://github.com/thx/rap2-dolores.git

六、切换到当前项目下分别创建Dockerfile和docker-compose.yml

1、创建Dockerfile添加如下内容

touch Dockerfile

vim Dockerfile

添加:

FROM node:10.1.0

MAINTAINER ryn

RUN mkdir -p /home/rap2-dolores

WORKDIR /home/rap2-dolores

COPY . /home/rap2-dolores

RUN npm install -g http-server

RUN npm install --unsafe-perm -g node-sass

RUN npm install

RUN npm run build

2、创建docker-compose.yml添加如下内容

touch docker-compose.yml

vim docker-compose.yml

添加:

version: '3.2'

services:
  delores:
    container_name: rap2-dolores
    build: .
    working_dir: /home/rap2-dolores
    environment:
      - NODE_ENV=production 
    command: /bin/sh -c 'http-server ./build -s -p 8081'
    privileged: true 
    ports:
      - "38081:8081"

七、修改src/config/config.prod.js

module.exports = {
  serve: 'http://你的服务器ip:38080',
  keys: ['some secret hurr'],
  session: {
    key: 'koa:sess'
  }
}

八、在当前目录下执行docker-compose up -d

查看容器是否创建并正常启动,通过http://你的服务器ip:38081

具体安装内容请参考:https://www.cnblogs.com/rynxiao/p/9080179.html,另外记住救命的sudo(如果你不是root账号登陆的)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值