tiredofit/docker-nginx-php-fpm

Install Openswoole

Stefan39 opened this issue · 2 comments

Hi, I'd like to install openswoole with an own Dockerfile, but i couldn't it to enable.

My Dockerfile

FROM tiredofit/nginx-php-fpm:debian-8.2

# additional ENV vars
ENV NODE_VERSION=20.5.1
ENV NVM_DIR=/root/.nvm

# Install NVM for node
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
RUN . "$NVM_DIR/nvm.sh" \
    && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" \
    && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" \
    && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"

# Install ffmpeg, npm and yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt update \
    && apt install vim ffmpeg nodejs yarn g++ make -y

RUN ln -s /bin/sed /usr/bin/sed

RUN php-ext enable sockets \
    && php-ext enable redis \
    #&& php-ext enable calendar \
    && php-ext enable zip \
    && pecl channel-update pecl.php.net \
    && pecl install --configureoptions 'enable-http2="yes" enable-openssl="yes"' openswoole-4.12.0 \
    && php-ext enable openswoole

#RUN echo 'extension=openswoole' >> $(php -i | grep /.+/php.ini -oE)
COPY php/openswoole.ini /etc/php/8.2/mods-available/openswoole.ini

The file openswoole.ini:

[Openswoole]
extension=openswoole

But if I'm build und start it, openswoole are not available. How can i enable it or is it possible to add it on your image?

Thanks for your great work ;-)

Oh interesting, you certainly figured out how to get things in there, so I'm surprised it's not working.

When you boot up your container, can you tell if it is loaded or not? (hint: look in /etc/php/*/conf.d and look for a symbolic link to look at mods-available.).

One thing I would add to your ini is the following:

;priority=00     ## Or 10 or 20

And then finally, in your Docker file would be to add the environment variable of PHP_ENABLE_OPENSWOOLE=TRUE which on container startup will enable it each time it starts. Let me know how that works for you.

Edit: you may like looking at some of my Dockerfiles for say Freescout or Bookstack to see how I use this base image downstream in my other images.

Hm, unfortunately not work only with PHP_ENABLE_OPENSWOOLE=true

The solution are to add RUN phpenmod openswoole on the end of the Dockerfile. So in fact:

FROM tiredofit/nginx-php-fpm:debian-8.2

# additional ENV vars
ENV NODE_VERSION=20.5.1
ENV NVM_DIR=/root/.nvm

# Install NVM for node
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
RUN . "$NVM_DIR/nvm.sh" \
    && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" \
    && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" \
    && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"

# Install ffmpeg, npm and yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt update \
    && apt install vim ffmpeg nodejs yarn g++ make -y

RUN ln -s /bin/sed /usr/bin/sed

RUN php-ext enable sockets \
    && php-ext enable redis \
    && php-ext enable zip \
    && pecl channel-update pecl.php.net \
    && pecl install --configureoptions 'enable-http2="yes" enable-openssl="yes"' openswoole-4.12.0 \
    && php-ext enable openswoole

COPY php/openswoole.ini /etc/php/8.2/mods-available/openswoole.ini
RUN phpenmod openswoole

EXPOSE 8080

Thanks for your great work