安装Docker
- 按照Docker官网的步骤执行(要注意自己系统的版本号)
https://docs.docker.com/compose/install/
Hello from Docker!
#安装成功后看到这句即可
安装Docker-compose
- 命令行如下顺序执行
$ curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
docker-compose version: 1.8.0
- 执行这几行命令,使用 Docker时 不用加
sudo
$ sudo groupadd docker
#将当前用户加入docker组
$ sudo gpasswd -a ${USER} docker
$ sudo service docker restart
克隆一期源码
- 选择好目录执行
$ git clone [email protected]:thoughtworks-academy/recruiting-system.git
$ git submodule init
$ git submodule update
开始环境配置
打开hosts文件,单独一行添加
127.0.0.1 local.twars
进入assembly,按顺序执行
$ docker-compose up -d mysql
assembly_mysql_1 is up-to-date
$ docker ps
#查看当前运行的容器,出现mysql:5.7即可
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6827bb303f9e mysql:5.7 "/entrypoint.sh mysql" 19 hours ago Up About an hour 0.0.0.0:3306->3306/tcp assembly_mysql_1
$ ./twars.sh
========= TWARS ===========
0--0^^^^^^^^^^^^\________
\__/||-------||---------~
`` ``
- 用法:(jk|rjk|bkjk|my|rs)
command:
jk 初始化jenkins
rjk 更新jenkins
my 初始化数据库和用户
rs 重启所有服务
bkjk 备份jenkins
$ ls
#查看数据库的初始化文件
assemble.sh* conf/ docker-compose-prod.yml logo nginx/ production.env remote_script twars-jenkins/
ci/ deploy-jenkins.sh* docker-compose.yml mysql-init.sql nodejs/ readme.md test.env twars.sh*
$ ./twars.sh my
#输入密码`"thoughtworks"`初始化数据库和用户
the password of root:
|
- 进入paper-api下按顺序执行
$ ./gradlew tasks
到这步你就可以去吃个饭了,因为不是一般的慢
$ ./gradlew flywaymigrate
$ docker ps
再次查看当前运行哪些容器,至少应该有mysql
$ docker exec -it `容器名/ID` bash
#此时的容器名应是 assembly_mysql_1
$ mysql -u root -pthoughtworks
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
$ show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| BronzeSword |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
$ use BronzeSword
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
$ show tables;
+------------------------+
| Tables_in_BronzeSword |
+------------------------+
| blankQuiz |
| blankQuizSubmit |
| homeworkPostHistory |
| homeworkQuiz |
| homeworkSubmit |
| itemPost |
| loginDetail |
| paper |
| passwordRetrieveDetail |
| quizItem |
| schema_version |
| scoreSheet |
| section |
| sectionQuiz |
| thirdParty |
| userDetail |
| users |
+------------------------+
17 rows in set (0.01 sec)
$ exit
#退出mysql
- 再次进入assembly下按顺序执行
$ ./twars.sh rs
如果提示说没有权限那就加上sudo
,然后就又可以去吃顿饭了
- 执行成功后访问
localhost:8888
,可看到登录页面,但没有验证码,如下图
- 切换到web-api下
$ gedit app.js
用//
注释这两行内容
var captcha = require('./middleware/captcha');
app.use(captcha(params));
- 切换到assembly下继续执行
$ docker-compose up -d
assembly_mongo_1 is up-to-date
assembly_mysql_1 is up-to-date
assembly_ambassador_1 is up-to-date
assembly_paper-api_1 is up-to-date
assembly_jenkins_1 is up-to-date
assembly_nginx_1 is up-to-date
Starting assembly_web-api_1
- 切换web-api下执行
$ npm i
- 切换到assembly下
$ docker ps -a
#查看隐藏的没有启动起来的容器
$ docker exec -it assembly_web-api_1 bash
root@ac59478f305a:/#
#输入 cd /var/app/
$ npm uninstall canvas
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info ok
$ npm install canvas
Ctral+d
#退出
- 取消之前在
web-api/app.js
中注释掉的两行 - 切换至assembly下
$ docker ps
#查看node : 5.8 是否是 up
如果是up
则执行这行命令
$ docker-compose kill web-api
$ docker-compose up -d
- 再次访问
localhost:8888
,看到验证码出现即成功,如下图
你会发现注册会显示错误,接着执行一下步骤
- 切换至web-api下,顺序执行
$ docker ps
$ docker exec -it 'mongo容器名/ID' bash
$ mongo
$ show dbs
$ use twars
$ db.createCollection('configurations');
$ db.configurations.insert({"registerable":true,"qaContent":""});
注册成功会后即可跳转至个人中心界面
- 修复不能显示图片的问题
修改recruiting-system/web-api/config/config.yml
里面的test属性的值为127.0.0.1
staticFileServer: 'http://127.0.0.1:8888/fs/'
- 切换到assembly
$ docker-compose kill web-api
$ docker-compose up -d
即可看到成功加载出来的图片