docker-webman/README.md
2024-07-19 11:53:27 +08:00

122 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 基于docker的webman
我们在php:8.1.27-cli基础上安装了运行webman必要的一些扩展和开发中常用的扩展以及composer制作成workerman:8.1.27镜像因此在开发环境中不需要再额外配置php环境直接写业务代码即可。
> 把镜像的tag换成8.2.20即可把php版本换成8.2.20
## 依赖
只要系统环境中有docker即可生产环境需要docker-compose不需要安装php环境。
## 使用方法
```sh
# composer
./composer require xxxx
# 启动服务
./php start.php start
# 执行其它php命令
./php -m
./php webman build:bin
```
## 生产环境使用
创建一个docker-compose.yml文件
```yml
services:
webman:
image: quay.io/wandoubaba517/workerman:8.1.27
container_name: webman
restart: always
volumes:
- ./:/app/service
working_dir: /app/service
stdin_open: true
ports:
- 8787:8787
# 部署生产时启动这一句
command: ['php', 'start.php', 'start']
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8787/"]
interval: 5s
retries: 3
start_period: 5s
timeout: 10s
```
然后直接执行前提要有docker-compose插件
```sh
docker compose up -d
```
## 一些有用的文件
|文件|作用|用法或说明|
|---|---|---|
|composer|调起容器中的composer命令的shell脚本|用法与主机中的compose完全一致./composer $args...|
|php|调起容器中的php命令的shell脚本|用法与主机中的php一致但注意执行./php start.php start命令时不要加-d参数|
|php.ini|映射到容器中的php.ini配置文件|容器中已经安装的扩展都有单独的配置文件,这里不会有体现|
## 已安装PHP扩展
```sh
php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
event
exif
fileinfo
filter
ftp
gd
gmp
hash
iconv
imagick
json
libxml
mbstring
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
sqlite3
standard
tokenizer
xlswriter
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
zookeeper
[Zend Modules]
Zend OPcache
```