Code Monkey home page Code Monkey logo

rap2-docker's Introduction

rap2-docker

Docker 上快速搭建 RAP2 应用。

安装

克隆仓库

git clone https://github.com/ganl/rap2-docker.git

初始化并更新submodule,主要是下载最新rap2-delos和rap2-dolores

git submodule init
git submodule update

#官方代码经常不能正常编译,可修改.gitmodules中的url为自己的fork库;修改后执行
git submodule sync
git submodule update --remote

修改配置

复制env文件

mv env-example .env

修改.env,主要的几个地方:

  • 修改dolores(前端)中访问delos(接口)服务serve相关值
# used in config.prod.ts, 
DELOS_SERVE_PROTOCOL=http
# local's IP or Domain or hostname
DELOS_SERVE_HOST=localhost
#Generally, same with DELOS_PORT, expose port
DELOS_SERVE_PORT=8888

后端和前端分离部署的(两个docker),此处配置会替换dolores的config.prod.ts中serve的值,修改后需要重新编译前端dolores镜像;如上配置dolores将通过 http://localhost:8888 访问后端delos

  • 修改本地存储路径

mysql存放路径,建议第一次部署确定好路径;修改路径数据不会自动Migrate,需手动导出再导入

DATA_PATH_HOST=~/.rap2/data

  • 修改DOLORES本地映射端口(镜像内运行端口80不可配,expose端口可配)

DOLORES_PORT=80

  • 修改DELOS运行端口(默认8080,代码取的环境变量SERVE_PORT的值)

DELOS_PORT=8880

修改DELOS_SERVE_PROTOCOLDELOS_SERVE_HOST以及DELOS_SERVE_PORT,需要执行docker-compose build dolores编译前端镜像;后端delos不用重新编译

使用

1 - 启动

docker-compose up dolores

➜  rap2-docker git:(master) docker-compose ps
     Name                   Command               State                 Ports               
--------------------------------------------------------------------------------------------
rap2_delos_1     node dispatch.js                 Up      0.0.0.0:8088->80/tcp              
rap2_dolores_1   /bin/sh -c http-server -s  ...   Up      0.0.0.0:8888->80/tcp              
rap2_mysql_1     docker-entrypoint.sh mysqld      Up      0.0.0.0:13306->3306/tcp, 33060/tcp
rap2_redis_1     docker-entrypoint.sh redis ...   Up      0.0.0.0:16379->6379/tcp

2 - 初始化DB

➜  rap2-docker git:(master) docker-compose exec delos sh
/app # node scripts/init

3 - 后台运行容器

docker-compose down
docker-compose up -d dolores

4 - 修改admin密码

docker-compose exec mysql bash

用.env中设定的密码登录数据库,默认root!pwd

#mysql -u root -p 
> use rap2
> update Users set password = '14e1b600b1fd579f47433b88e8d85291' where fullname = 'admin';

修改后的admin密码为123456,初始化的登录邮箱为[email protected]

升级

1 - 升级DB

➜  rap2-docker git:(master) docker-compose exec delos node scripts/updateSchema

/app # node scripts/updateSchema

2 - 升级镜像

docker-compose down
# 重新构建并启动
docker-compose up --build -d dolores

docker image prune -f

[Docker]常用命令

列出正在运行的容器

docker ps

你也可以使用以下命令查看某项目的容器

docker-compose ps

关闭所有容器

docker-compose stop

停止某个容器:

docker-compose stop {容器名称}

删除所有容器

docker-compose down

进入容器 (通过 SSH 进入一个运行中的容器)

1 - 首先使用 docker ps 命令查看正在运行的容器

2 - 进入某个容器使用:

docker-compose exec {container-name} bash # mysql redis
docker-compose exec {container-name} sh   # delos dolores

例如: 进入 MySQL 容器

docker-compose exec mysql bash

3 - 退出容器, 键入 exit.

[使用阿里云镜像加速]

el7

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

sudo service docker start

修改daemon配置文件/etc/docker/daemon.json来使用加速器, 加速地址获取:https://cr.console.aliyun.com/cn-hangzhou/mirrors

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://9cujqpdr.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

rap2-docker's People

Contributors

ganl avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

rap2-docker's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.