All Projects → swoft-cloud → Alphp

swoft-cloud / Alphp

Licence: mit
A micro PHP Docker environment based on an Alpine image. Can be used for container publishing, the completed image is only 30-40M

Projects that are alternatives of or similar to Alphp

php7-alpine
Docker container for PHP 7 in Alpine Linux, with almost all extensions that you may need
Stars: ✭ 20 (-80%)
Mutual labels:  alpine, swoole
static-php-cli
Build single static PHP binary in linux, build with PHP project together, with Swoole and other popular extensions included.
Stars: ✭ 129 (+29%)
Mutual labels:  alpine, swoole
docker-swoole-webapp
Simple Docker-image to build your applications based on Async PHP extensions.
Stars: ✭ 26 (-74%)
Mutual labels:  alpine, swoole
docker-laravel-appengine
Laravel dockerized with official Google App Engine flexible php environment + swoole.
Stars: ✭ 66 (-34%)
Mutual labels:  alpine, swoole
Iron Alpine
Hardened alpine linux baseimage for Docker.
Stars: ✭ 84 (-16%)
Mutual labels:  alpine
Php Coroutine Engine
This project for php-fpm support coroutine
Stars: ✭ 74 (-26%)
Mutual labels:  swoole
Dockerfile
📦 Dockerfiles from WebDevOps for PHP, Apache and Nginx (with PHP5 and PHP7)
Stars: ✭ 1,169 (+1069%)
Mutual labels:  alpine
Swoft Framework
[READ ONLY] Swoft Framework, base of Swoft
Stars: ✭ 70 (-30%)
Mutual labels:  swoole
Swoft Game
基于swoft框架开游戏服务器框架
Stars: ✭ 97 (-3%)
Mutual labels:  swoole
Uvicorn Gunicorn Starlette Docker
Docker image with Uvicorn managed by Gunicorn for high-performance Starlette web applications in Python 3.7 and 3.6 with performance auto-tuning. Optionally with Alpine Linux.
Stars: ✭ 92 (-8%)
Mutual labels:  alpine
Mix Phar Skeleton
Phar command line program development skeleton
Stars: ✭ 81 (-19%)
Mutual labels:  swoole
Docker Openldap
Docker OpenLDAP Container w/TLS & Replication Support S6 Overlay, and Zabbix Monitoring based on Alpine
Stars: ✭ 74 (-26%)
Mutual labels:  alpine
Yii2 Swoole
full solutions making yii2-framework run on swoole with coroutine.
Stars: ✭ 86 (-14%)
Mutual labels:  swoole
Mqtt
🕹 MQTT Protocol Analysis and Coroutine Client for PHP. Support for 3.1, 3.1.1 and 5.0 versions of the MQTT protocol.
Stars: ✭ 72 (-28%)
Mutual labels:  swoole
Docker Oidc Proxy
Docker Image built on Alpine Linux for secure OpenID Connect (OIDC) proxy authentication
Stars: ✭ 91 (-9%)
Mutual labels:  alpine
Alpine Phoenix Builder
Up to date Alpine image with the latest language versions for staged Elixir and Phoenix builds.
Stars: ✭ 71 (-29%)
Mutual labels:  alpine
Ycsocket
基于swoole的socket框架,支持协程版MySQL、Redis连接池,已用于大型RPG游戏服务端
Stars: ✭ 77 (-23%)
Mutual labels:  swoole
Swoole Source Analysis
swoole source reading 源码分析
Stars: ✭ 88 (-12%)
Mutual labels:  swoole
Docker Alpine Python Machinelearning
Small Docker image with Python Machine Learning tools (~180MB) https://hub.docker.com/r/frolvlad/alpine-python-machinelearning/
Stars: ✭ 76 (-24%)
Mutual labels:  alpine
Slim Swoole
Convenient library to run SlimPHP applications with Swoole
Stars: ✭ 75 (-25%)
Mutual labels:  swoole

Alpine PHP Docker

Docker Build Status Docker Pulls MicroBadger Layers (tag) MicroBadger Size (tag)

alphp - 基于alpine的微型php docker环境,php 是 7.x, 包含最新版本swoole。 构建完成的镜像只有30-40M,可以直接用于生产环境作镜像发布。

共有几个镜像

  • swoft/alphp:base 基础镜像,后几个镜像基于它(含有php和一些通用的扩展)
  • swoft/alphp:cli php cli环境镜像,含有最新版本 swoole 和 mongodb 扩展
  • swoft/alphp:fpm 基于 swoft/alphp:cli,含有 nginx php-fpm 组件
  • swoft/alphp:dev 基于 swoft/alphp:cli,含有 nginx php-fpm 以及一些常用工具:vim wget git zip telnet ab 等,可用于开发。

共有几个分支

  • master: 基于 alpine:3.8 镜像, php7.2
  • alpine-edge: 基于 alpine:edge 镜像, php7.2
  • alpine-3.7: 基于 alpine:3.7 镜像, php7.1

Dockerfile links

base on alpine 3.8(php 7.2.x):


直接拉取

docker pull swoft/alphp:base
docker pull swoft/alphp:cli
docker pull swoft/alphp:fpm
docker pull swoft/alphp:dev

hub.docker 地址: https://hub.docker.com/r/swoft/alphp/

本地构建

构建基础镜像

docker build . -f alphp-base.Dockerfile -t swoft/alphp:base

构建功能镜像

  • 构建 swoft/alphp:cli
docker build . -f alphp-cli.Dockerfile -t swoft/alphp:cli
  • 构建 swoft/alphp:fpm
// 在swoft/alphp:cli 的基础上,含有 nginx php-fpm
docker build . -f alphp-fpm.Dockerfile -t swoft/alphp:fpm
  • 构建 swoft/alphp:dev
// 在 swoft/alphp:cli 的基础上,含有 nginx php-fpm 额外包含一些常用工具:vim wget git zip telnet ab 等
docker build . -f alphp-dev.Dockerfile -t swoft/alphp:dev

一些有用的

更改软件源

sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories

Dockerfile注意

  • 如果想要主进程接收 docker stop 信号(SIGTERM),一定要用 ENTRYPOINT 或者 RUN 来启动运行主进程,不能使用 CMD。

CMD 会始终使用 sh -c command 来执行命令,这样PID = 1 的就不是真实命令所在进程了

ENTRYPOINT ["php", "/var/www/bin/cli", "taskServer:restart"]

镜像中的一些信息

  • php execute file: /usr/bin/php
  • php ini file: /etc/php7/php.ini
  • 扩展配置目录:/etc/php7/conf.d
  • 扩展编译目录:/usr/lib/php7/modules
  • php-fpm execute file: /usr/bin/php-fpm
  • php-fpm conf: /etc/php7/php-fpm.conf

重新生成 composer autoload

composer up nothing

工具推荐

工具列表

  • composer 包管理
  • phpunit 单元测试
  • phpmd 代码检查
  • 类参考文档生成
  • deployer 一个用PHP编写的部署工具支持流行的框架
  • xhprof 安装

add composer

ADD tools/composer.phar /usr/local/bin/composer
RUN chmod 755 /usr/local/bin/composer

类参考文档生成

  • 使用 sami(推荐)
$ ./vendor/bin/sami.phar -V

生成:

$ php ./vendor/bin/sami.phar update build/sami.conf.php

分开执行:

// The parse command parses a project and generates a database
$ php ./vendor/bin/sami.phar parse config/symfony.php

// The render command renders a project as a static set of HTML files
$ php ./vendor/bin/sami.phar render config/symfony.php
  • 使用 apigen
$ ./vendor/bin/apigen.phar -V
$ ./vendor/bin/apigen.phar generate --help
$ ./vendor/bin/apigen.phar generate -s {source code dir} -d {doc generate dir}
  • 使用phpDocumentor
$ ./vendor/bin/phpDocumentor.phar -V
phpDocumentor version v2.9.0
$ ./vendor/bin/phpDocumentor.phar run -d {source code dir} -t {doc generate dir}

手动管理 php-fpm

#关闭php-fpm
kill -INT `cat /usr/local/php/var/run/php-fpm.pid`

#重启php-fpm
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

端口检查 lsof

lsof :9051

ab 压力测试

安装

// ubuntu
apt-get install apache2-utils
// centos
yum install httpd-tools

安装 swoole

官网 swoole.com 安装相关扩展 redis, zip, mbstring, inotify, pdo_mysql

相关库

编译命令

# phpize
# ./configure --enable-swoole-debug --enable-async-redis --enable-openssl --enable-sockets --enable-coroutine --with-php-config=/usr/local/bin/php-config
# make clean
# make -j
# make install

更多选项说明

使用 ./configure -h 可以看到全部的选项

  • --enable-swoole-debug // 打开调试日志,开启此选项后swoole将打印各类细节的调试日志。生产环境不要启用。
  • --enable-sockets // 增加对sockets资源的支持,依赖sockets扩展
  • --enable-async-redis // 增加异步Redis客户端支持, 依赖hiredis库
  • --enable-openssl // 启用SSL支持,依赖openssl库
  • --enable-http2 // 增加对HTTP2的支持,依赖nghttp2库. 必须开启openssl
  • --enable-coroutine // 启用协程能力(swoole 4 已去除此选项)

相关库

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].