添加 docker 镜像文件

This commit is contained in:
jerrylizilong 2018-12-19 19:24:51 +08:00
parent b3a14fd185
commit ddc2d57b33
3 changed files with 41 additions and 0 deletions

12
app/dockerfile/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM jerry-sample-flask
LABEL author="jerry"
RUN echo "start"
USER root
RUN echo "using user root"
WORKDIR /opt/app-root/src
RUN echo "enter worksdir"
RUN pwd
COPY runall.sh /opt/app-root/src/runall.sh
RUN chmod +x /opt/app-root/src/runall.sh
RUN echo "chmod" && ls
ENTRYPOINT ["/opt/app-root/src/runall.sh"]

23
app/dockerfile/docker.md Normal file
View File

@ -0,0 +1,23 @@
## 1. 使用 s2i 从github 获取最新代码并构建镜像:
- 安装 s2i 服务。 参考: https://github.com/openshift/source-to-image
- 拉取所需的 python-35-centos7 镜像: docker pull python-35-centos7
- 使用 s2i 构建镜像:
```
s2i build https://github.com/jerrylizilong/autotest_platform.git centos/python-35-centos7 jerry-sample-flask
```
## 2.基于新生成的镜像,创建可运行的 flask 镜像:
- 新建目录,复制 Dockerfile 和 runall.sh 到该目录中。
- 在该目录中构建镜像: docker build -t jerry/jerrynewflask:v1 .
### 3. 启动容器:
```
docker run -d -t -p 5001:5000 --net grid --link mysql:mysql --link selenium-hub:selenium --name flask1 648f9459184e
```
### 4. 进入容器中,修改 config 文件:
```
docker exec -it flask1 bash
```
修改 /opt/app-root/src/app/config.py 文件中的配置。

6
app/dockerfile/runall.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
echo "start running"
pwd
nohup python3 /opt/app-root/src/run.py &
nohup python3 /opt/app-root/src/core.py &
tail -f requirements.txt