安装配置 Cloud9 的原因
日常工作中可能需要使用 Web IDE 进行代码展示或存储,经过查询,Eclipse Che 和 Cloud9 是两款优秀的 Web IDE,先选择 Cloud9 进行安装试用。
在寻找 Docker 仓库中发现了 kdelfour/cloud9-docker,试用过程中发现下列几个问题
- 没有安装 JDK,不能进行 Java 代码编译运行
- 系统是 Ubuntu 14.04.2 LTS
- 默认端口号是 80
为了解决这些问题,开始搭建符合自己需求的 Cloud9 容器
安装步骤
一. 安装 Docker CE (社区版)
- Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
1 | yum install -y yum-utils device-mapper-persistent-data lvm2 |
- Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
1 | yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo |
- Install the latest version of Docker CE, or go to the next step to install a specific version:
1 | yum install docker-ce |
- Start Docker and check docker version
1 | systemctl start docker |
二. 获取 centos7 容器的镜像
- 配置国内镜像仓库
1 | echo "DOCKER_OPTS=\"--registry-mirror=http://hub-mirror.c.163.com\"" >> /etc/default/docker |
- 查找 centos7 镜像
1 | docker search centos |
- 下载镜像
1 | docker pull centos |
三. 安装 OpenJDK
启动 centos 容器
–network=host 让容器使用主机的 IP 地址
-v 配置路径 workspace 是 cloud9 将要使用的路径
1 | docker run -it -d --name cloud9 --network=host -v /data/workspace/:/workspace/ centos |
四. 安装编译 Cloud9
- 安装编译环境
1 | yum install -y build-essential g++ curl libssl-dev apache2-utils git libxml2-dev sshfs |
- 安装 Node.js
1 | curl -sL https://rpm.nodesource.com/setup_11.x | bash - |
- 安装 Cloud9
1 | git clone https://github.com/c9/core.git /cloud9 |
- 配置 cloud9.conf 文件
vi /etc/supervisor/conf.d/cloud9.conf
[program:cloud9]
command = node /cloud9/server.js --listen 0.0.0.0 --port 80 -w /workspace
directory = /cloud9
user = root
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/cloud9.log
stderr_logfile = /var/log/supervisor/cloud9_errors.log
environment = NODE_ENV="production"
node 启动参数说明:
–settings Settings file to use 设置启动配置文件
–help Show command line options.帮助
-t Start in test mode 启动测试模式
-k Kill tmux server in test mode 在测试模式中杀死tmux终端
-b Start the bridge server - to receive commands from the cli [default: false]
-w Workspace directory 设置工作目录
–port Port 端口号
–debug Turn debugging on 启动调试模式
–listen IP address of the server 侦听ip,默认应该是0.0.0.0
–readonly Run in read only mode 只读模式,不能进行修改文件等操作
–packed Whether to use the packed version. 使用打包好的版本
–auth Basic Auth username:password 登陆时时使用http auth认证 设置用户名密码
–collab Whether to enable collab. 是否设置collab
–no-cache Don’t use the cached version of CSS 不进行缓存
- 设置自启动
Supervisor 是一个用 Python 写的进程管理工具,可以很方便的用来启动、重启、关闭进程(不仅仅是 Python 进程)。除了对单个进程的控制,还可以同时启动、关闭多个进程,比如很不幸的服务器出问题导致所有应用程序都被杀死,此时可以用 supervisor 同时启动所有应用程序而不是一个一个地敲命令启动。
1 | yum install python-setuptools -y |
启动界面
Supervisor 安装与配置可参考: