|
|
@ -53,3 +53,68 @@ drive.yixinhuixiang.com |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 打包一个镜像到rainbond |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 文件准备 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
准备好需要打包的html包,确认下一层级就有html文件 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
写好dockerfile 这是制作镜像的描述 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
例子: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
FROM nginx |
|
|
|
|
|
|
|
# dist 文件结构是 ./dist/index.html |
|
|
|
|
|
|
|
COPY ./dist /usr/share/nginx/html |
|
|
|
|
|
|
|
COPY ./default.conf /etc/nginx/conf.d/ |
|
|
|
|
|
|
|
EXPOSE 80/tcp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
如果必要修改nginx配置,比如做本地反向代理,或者是调整上下载限制,就写一份nginx的配置文件 ,跟着镜像一起打包 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
反向代理设置选项请参考nginx配置帮助 [nginx帮助](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
反向代理可以让访问应用特定地址,转发到目标,从而避开跨域,或者复杂环境等情况。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
# 这个配置将导致访问应用/app/后缀的直接转发到www.baidu.com |
|
|
|
|
|
|
|
location /app/ { |
|
|
|
|
|
|
|
proxy_pass http://www.baidu.com; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
### 镜像操作 |
|
|
|
|
|
|
|
准备好后,在dockerfile 目录执行 |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
docker build . -t $name |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$name = 镜像名称(私有仓库请写全部 比如:) |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
docker build . -t registry.cn-beijing.aliyuncs.com/zsw2023/mini_game |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
由于docker hub太慢,我们外部仓库放置镜像加速拉取,用阿里云或者青云。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
阿里云的操作举例: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
# 把本地镜像改名成能推的 不带版本号默认最新:latest |
|
|
|
|
|
|
|
docker tag nginx:v2 registry.cn-beijing.aliyuncs.com/zsw2023/nginx |
|
|
|
|
|
|
|
# 登录阿里云 |
|
|
|
|
|
|
|
docker login registry.cn-beijing.aliyuncs.com |
|
|
|
|
|
|
|
# 推 |
|
|
|
|
|
|
|
docker push registry.cn-beijing.aliyuncs.com/zsw2023/mini |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 应用发布 |
|
|
|
|
|
|
|
由于我们服务器应用demo设置了registry.cn-beijing.aliyuncs.com/zsw2023/mini作为拉取构建镜像, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
推送完成后服务器直接点构建,就可以更新。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
![docker](img/rainbond-container.png) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|