Giter Club home page Giter Club logo

docker-workerman's Introduction

中文 English

workerman的php生产环境 docker镜像

已安装的php扩展: redis mysql event

已安装的工具: git composer

出于安全考虑,容器并没有以root身份运行,默认的运行用户是 workerman (uid=1000,gid=1000),socket的监听端口必须大于1024。

可选环境参数

变量名 类型 默认值 描述
DEBUG_ENTRYPOINT int 0 输出容器启动阶段的设置与运行的命令。
取值:
0: 关闭输出
1: 只输出设置
2: 输出所有设置与运行的命令
TIMEZONE string UTC 设置容器的时区。
(例如: Asia/Shanghai)
NEW_UID int 1000 给容器内默认运行用户设置一个新uid。
当挂载了本地目录到容器内部时,设置该参数为本地用户uid,可统一容器内与本地的文件权限。(运行 id -u 命令 查看当前用户uid)。
NEW_GID int 1000 给容器内默认运行用户组设置一个新gid。
当挂载了本地目录到容器内部时,设置该参数为本地用户组gid,可统一容器内与本地的文件权限。(运行 id -g 命令 查看当前用户组gid)。

1. 运行workerman容器

$ docker run -d --net=host --name workerman \
        -e DEBUG_ENTRYPOINT=1 \
        -e NEW_UID=$(id -u) \
        -e NEW_GID=$(id -g) \
        -e TIMEZONE=Asia/Shanghai \
        jaredlee/workerman

2. 获取workerman框架(如果已有workerman框架,可以跳过此步)

$ docker exec -it workerman \
        composer require workerman/workerman

3. 启动workerman项目

# id -u 获取当前用户uid
# id -g 获取当前用户组gid

# 以普通模式运行

$ docker exec -it workerman \
        php /workdir/your_project_start_file_path start

# 检查普通模式的log输出
$ docker logs workerman


# 以后台daemon模式运行
$ docker exec -it workerman \
        php /workdir/your_project_start_file_path start -d

# 检查daemon模式的log输出
# daemon模式的log输出位于项目目录下的log文件内

PHP production environment for workerman docker image

Installed PHP extensions: redis mysql event

Installed Tools: git composer

For security reason, container is not running as root, the defalut user runs in container is workerman (uid=1000,gid=1000) and sockets can only listen to ports above 1024

Optional environmental variables

Variable Type Default Description
DEBUG_ENTRYPOINT int 0 Show settings and shell commands executed during startup.
Values:
0: Off
1: Show settings
2: Show settings and commands
TIMEZONE string UTC Set docker OS timezone.
(Example: Europe/Berlin)
NEW_UID int 1000 Assign the default Nginx user a new UID. This is useful if you you mount your document root and want to match the file permissions to the one of your local user. Set it to your host users uid (see id -u for your uid).
NEW_GID int 1000 This is useful if you you mount your document root and want to match the file permissions to the one of your local user group. Set it to your host user groups gid (see id -g for your gid).

1. Startup a container

$ docker run -d --net=host --name workerman \
        -e DEBUG_ENTRYPOINT=1 \
        -e NEW_UID=$(id -u) \
        -e NEW_GID=$(id -g) \
        -e TIMEZONE=Europe/Berlin \
        jaredlee/workerman

2. Get workerman framework(skip this if you already has workerman framework)

$ docker exec -it workerman \
        composer require workerman/workerman

3. Start your workerman project

# id -u get current user uid
# id -g get current user group gid

# Start in normal mode
$ docker exec -it workerman \
        php /workdir/your_project_start_file_path start

# Check logs in normal mode
$ docker logs workerman


# Start in daemon mode
$ docker exec -it workerman \
        php /workdir/your_project_start_file_path start -d

# Check logs in daemon mode
# See log files in your project path

docker-workerman's People

Watchers

CallOrRet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.