1 Star 5 Fork 1

ziyoren / webman-docker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Webman Docker

1、构建镜像

构建自己的镜像,首先是为了满足项目需求。一些官方镜像不包含的扩展可以自己添加进去。其次,在开发调试阶段就用自己的镜像,若是PHP环境有问题,可以及时发现并加以完善。第三,在自己的镜像基础上,把开发好的应用再次构建成生产环境镜像。用生产镜像去部署生产服务器就十分方便啦!

在php目录下运行下面的构建命令

cd php
docker build -t ziyo-php:8.1.28-cli-alpine .

因为PHP官方的Docker镜像包含的扩展无法满足我们项目的需求,所以要根据项目进行php环境的配置。

php/Dockerfile为本项目集成了包管理工具composer和以下扩展:

  • event
  • bcmath
  • mysqli
  • pdo_mysql
  • fileinfo
  • pcntl
  • redis
  • memcached
  • mongodb

2、Docker开发容器

应用开发阶段可以用下面的命令启动一个容器,进行开发调试

docker run -itd --name ziyo-webman -p 8787:8787 -e TZ="Asia/Shanghai" -v ./src:/www  ziyo-php:8.1.28-cli-alpine

启动您的应用

打开一个终端

docker exec -it ziyo-webman /bin/sh

安装Webman(需要手动安装一下。当然也可以直接把现有的webman项目,复制到src目录里)

cd /www
composer create-project workerman/webman .

启动Webman

cd /www
php start.php start

访问您的应用: http://localhost:8787

3、构建生产镜像

基于项目根目录下的Dockerfile构建出生产环境的镜像

docker build -t ziyo-webman-production .

生产镜像的使用说明

docker run -itd --restart=always --name ziyo-webman -p 8080:8787 ziyo-webman-production

--restart=always 重启策略很重要。当webman进程异常退出会导致容器的运行的中止,这时重启策略起作用,就可以自动重启容器并运行PHP服务。

相关链接

MIT License Copyright (c) 2024 ziyoren Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

适用webman框架的docker镜像 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Docker
1
https://gitee.com/ziyoren/webman-docker.git
git@gitee.com:ziyoren/webman-docker.git
ziyoren
webman-docker
webman-docker
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891