title: Docker meta:

  • name: description Content: EasySwoole docker image build
  • name: keywords Content: swoole|swoole extension|swoole framework|easyswoole|swoole docker image|swoole dockerfile

Docker

docker pull

  1. docker pull easyswoole/easyswoole3

::: warning The environment on the docker hub is php7.1.30 + swoole4.4.3 :::

Start up

  1. docker run -ti -p 9501:9501 easyswoole/easyswoole3

The default working directory is: /easyswoole. When the above command is started, it automatically enters the working directory, executes php easyswoole start, and the browser accesses http://127.0.0.1:9501/ You can see the easyswoole welcome page.

Docker File

You can also use Docker file for automatic builds.

  1. FROM centos:latest
  2. #version defined
  3. ENV SWOOLE_VERSION 4.4.3
  4. ENV EASYSWOOLE_VERSION 3.x-dev
  5. #update core
  6. RUN yum update -y
  7. #install libs
  8. RUN yum install -y curl zip unzip wget openssl-devel gcc-c++ make autoconf
  9. #install php
  10. RUN yum install -y epel-release
  11. RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  12. RUN yum clean all
  13. RUN yum update -y
  14. RUN yum install -y php71w-devel php71w-openssl php71w-gd php71w-mbstring php71w-mysqli
  15. # composer
  16. RUN curl -sS https://getcomposer.org/installer | php \
  17. && mv composer.phar /usr/bin/composer \
  18. && composer self-update --clean-backups
  19. # use aliyun composer
  20. RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
  21. # swoole ext
  22. RUN wget https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz -O swoole.tar.gz \
  23. && mkdir -p swoole \
  24. && tar -xf swoole.tar.gz -C swoole --strip-components=1 \
  25. && rm swoole.tar.gz \
  26. && ( \
  27. cd swoole \
  28. && phpize \
  29. && ./configure --enable-openssl \
  30. && make \
  31. && make install \
  32. ) \
  33. && sed -i "2i extension=swoole.so" /etc/php.ini \
  34. && rm -r swoole
  35. # Dir
  36. WORKDIR /easyswoole
  37. # install easyswoole
  38. RUN cd /easyswoole \
  39. && composer require easyswoole/easyswoole=${EASYSWOOLE_VERSION} \
  40. && php vendor/bin/easyswoole install
  41. EXPOSE 9501