Skip to content

⚙️ Docker image for Swoole apps with Composer, auto-restart on development and a production-ready version.

License

Notifications You must be signed in to change notification settings

leocavalcante/dwoole

Repository files navigation

⚠️ First, I'd like to invite you to take a look at the official Swoole image: https://hub.docker.com/r/phpswoole/swoole

Dwoole

Docker image for Swoole apps with Composer, auto-restart on development and a production-ready version.

Usage

Requirements

  • composer.json
  • index.php (this will be your entry-point)

Entry-point file can be overridden with the environment variable ENTRY_POINT_FILE. See this for an example.

Exposed port is 9501

Using Docker Compose?

A docker-compose.yml file would look like:

version: "3"
services:
  web:
    container_name: my_app
    image: leocavalcante/dwoole:dev
    volumes:
      - ./:/app
    ports:
      - "9501:9501"

Yeah! Simple like that.

What is inside?

Options enabled:

  • --enable-openssl
  • --enable-sockets
  • --enable-http2
  • --enable-mysqlnd

Development

Comes bundled with:

  • sdebug
  • Hot-restart
  • PDO MySQL & MySQLi
  • MongoDB
  • Redis

Watch interval can be overridden with the environment variable WATCH_INTERVAL.

Production

Comes bundled with:

  • Nothing

It is Swoole only. That is because only you knows what your project really needs. The recommended way to use the production variant is as a base image for you project image.

FROM leocavalcante/dwoole:prod
# Add only what your project really needs
COPY . /app

Then you can add whatever extensions you would like.

Adding PHP extensions
RUN apk add --no-cache freetype-dev libjpeg-turbo-dev libpng-dev libzip-dev \
 && docker-php-ext-configure gd && docker-php-ext-install -j$(nproc) gd zip
Adding PECL extensions
RUN pecl install mongodb \
  && docker-php-ext-enable mongodb
RUN pecl install redis \
  && docker-php-ext-enable redis

Why not inotify?

⚠ Dwoole will always commit to the latest PHP and Swoole versions.