Recently I've decided to check out the Symfony Panther HTTP Client. I thought it would be nice to integrate that for testing and things.
I did follow the documentation very carefully. I have registered its extension for PHP unit. I can create a Panther client after extending the Panther Test Case - no problem there.
Problem shows when I try to make an actual call. Let's say:
$client = static::createPantherClient([ "--no-sandbox", "--headless", "window-size=1024,768"]);
$client->request('GET', '/mypage');
These options in the array - I was just trying things out, I thought it might help. The error I am getting is as follows:
1) App\Tests\Integration\Container\Controllers\ContainerControllerTest::test_read_container_by_slug
Facebook\WebDriver\Exception\UnknownErrorException: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
I did look at the docs and SO for a solution but I can't really find anything that would help me.
Does anyone know why this is happening?
This is my Dockerfile for PHP
FROM php:7.4.3-fpm-alpine
WORKDIR /srv/app/
RUN apk update
RUN echo "extension=pdo_mysql" >> /usr/local/etc/php/php.ini-development
RUN docker-php-ext-install -j$(nproc) pdo_mysql
# php-redis
ENV PHPREDIS_VERSION 5.0.2
RUN docker-php-source extract \
&& curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
&& docker-php-ext-install redis \
&& docker-php-source delete
RUN apk add --no-cache \
unzip \
chromium \
chromium-chromedriver
ENV PANTHER_CHROME_DRIVER_BINARY /usr/lib/chromium/chromedriver
RUN docker-php-ext-install opcache
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY conf/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
Related
I am trying to install OCI8 extension on my Alpine Linux Docker environment. Although there are several places saying it won't work, there are some which say it actually does. I have a 3.4 version and for corporate reasons it is staying like that for now.
I have done this within my Docker conf:
# Install Oracle Client and build OCI8 (Oracel Command Interface 8 - PHP extension)
USER root
ENV LD_LIBRARY_PATH=/usr/local/instantclient
ENV ORACLE_HOME=/usr/local/instantclient
RUN apk update && apk upgrade
RUN apk add musl-dev libaio autoconf && apk add --update make
## Unzip Instant Client v12
RUN pecl channel-update pecl.php.net
COPY instantclient_12_2.zip /var/www/html/instantclient_12_2.zip
RUN unzip -d /usr/local/ /var/www/html/instantclient_12_2.zip
RUN ln -s /usr/local/instantclient_12_2 /${ORACLE_HOME} && \
ln -s /${ORACLE_HOME}/libclntsh.so.* /${ORACLE_HOME}/libclntsh.so && \
ln -s /${ORACLE_HOME}/libocci.so.* /${ORACLE_HOME}/libocci.so && \
ln -s /${ORACLE_HOME}/lib* /usr/lib && \
ln -s /${ORACLE_HOME}/sqlplus /usr/bin/sqlplus &&\
ln -s /usr/lib/libnsl.so.2.0.0 /usr/lib/libnsl.so.1
RUN apk add gcc; exit 0 # This has a history of failing sometimes
RUN echo "instantclient,/usr/local/instantclient" | pecl install oci8 &&\
echo 'extension=oci8.so' > /usr/local/etc/php/conf.d/30-oci8.ini &&\
rm -rf /tmp/*.zip /var/cache/apk/* /tmp/pear/
Now the build passes, and it looks okay, however when I do a php -v I am getting the following:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/no-debug-non-zts-20160303/oci8.so' -
Error loading shared library libnsl.so.1: No such file or directory
(needed by /usr/local/instantclient/libclntsh.so.12.1) in Unknown on
line 0
PHP version is 7.1.12.
What I've tried is doing apk add libnsl but this returns me this error:
ERROR: unsatisfiable constraints: so:libtirpc.so.3 (missing):
So I tried also adding apk add libtirpc-dev (the 'plain' libtirpc isn't available for my version or something), but that changed nothing.
Any clues?
I share my version of docker that I made to work with the latest version of alpine and instantclient basiclite. The size of the docker image is 124 mb.
I share my github where you can download it
Docker + alpine + Instantclient Basiclite
Or you can see below the content of the dockerfile
FROM alpine:latest
# Install Instantclient Basic Light Oracle and Dependencies
RUN apk --no-cache add libaio libnsl libc6-compat curl && \
cd /tmp && \
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
unzip instantclient-basiclite.zip && \
mv instantclient*/ /usr/lib/instantclient && \
rm instantclient-basiclite.zip && \
ln -s /usr/lib/instantclient/libclntsh.so.19.1 /usr/lib/libclntsh.so && \
ln -s /usr/lib/instantclient/libocci.so.19.1 /usr/lib/libocci.so && \
ln -s /usr/lib/instantclient/libociicus.so /usr/lib/libociicus.so && \
ln -s /usr/lib/instantclient/libnnz19.so /usr/lib/libnnz19.so && \
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 && \
ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2
ENV ORACLE_BASE /usr/lib/instantclient
ENV LD_LIBRARY_PATH /usr/lib/instantclient
ENV TNS_ADMIN /usr/lib/instantclient
ENV ORACLE_HOME /usr/lib/instantclient
I might be late to answer this. I got the same problem of having a alpine base image and add oracle client to that. So i came up with this solution -
https://github.com/Shrinidhikulkarni7/OracleClient_Alpine
Here is the Dockerfile, but you would also need the shell script in it for it to work.
FROM alpine:latest
ENV LD_LIBRARY_PATH=/lib
RUN wget https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \
unzip instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \
cp -r instantclient_19_3/* /lib && \
rm -rf instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \
apk add libaio
ADD script.sh /root/script.sh
RUN /root/script.sh
Over here I'm directly downloading the oracle client inside image, setting the path, adding packages and finally using the shell script for creating symbolic link.
I'd recommend using an operating system supported by Oracle, thus avoiding the headache of hacking Alpine and the uncertainty that it won't fall over at a critical time. And thus giving you some confidence your business won't be negatively impacted. Try https://github.com/oracle/docker-images/tree/master/OracleInstantClient
Other comments
Don't set ORACLE_HOME when using Instant Client. That variable is
for full software installs.
Use ldconfig to set the system library path, see
the Instant Client installation instructions e.g. here.
Use Instant Client 19, which can connect to the same DB versions that 12.2 can. (19 is really the renamed terminal 12.2 release in the new versioning system)
Using Oracle Linux Docker images has the advantage that it will download and install the 19 Instant Client without you having to manually do the download.
See this blog for info about the 'slim' Oracle Linux container it uses.
Here is the Dockerfile For Golang With ORACLE-CLIENT
FROM golang:alpine
RUN apk update
ENV CLIENT_FILENAME instantclient-basic-linux.x64-12.1.0.1.0.zip
WORKDIR /opt/oracle/lib
ADD https://github.com/bumpx/oracle-instantclient/raw/master/${CLIENT_FILENAME} .
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk add --update libaio libnsl && \
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1
RUN LIBS="*/libociei.so */libons.so */libnnz12.so */libclntshcore.so.12.1 */libclntsh.so.12.1" && \
unzip ${CLIENT_FILENAME} ${LIBS} && \
for lib in ${LIBS}; do mv ${lib} /usr/lib; done && \
ln -s /usr/lib/libclntsh.so.12.1 /usr/lib/libclntsh.so && \
rm ${CLIENT_FILENAME}
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN apk add git
RUN apk add libc-dev
RUN apk add gcc
RUN go mod tidy
RUN go build -o main .
CMD ["/app/main"]
I was just tackling a similar problem to this using the Godror Golang Driver for Oracle. I was never able to solve this on using an Alpine image. The problem eventually came that libint.sh, would never fully install to be recognized by the system. Even changing the docker file to using the Glibc library.
How i eventually fixed the issue was to use the images from Oracle itself. The full version not the slim images that can be seen here: https://github.com/oracle/docker-images/tree/master/OracleLinuxDevelopers
you then have to install golang and then your Instant client and Oracle dependencies if you need it.
FROM oraclelinux:7 as builder
RUN yum install -y oracle-golang-release-el7 && \
yum install -y git && \
yum install -y golang unzip
COPY . /app
RUN go version
WORKDIR /app
{Your Docker Specific Commands Here}
{Insert Build Specific Environment Variables here}
#Oracle Specific Environment Variables
{Insert Oracle Env Variables here}
WORKDIR /root/
#Install oracle dependencies
RUN yum install -y wget unzip libaio && \
rm -rf /var/cache/yum
#install Oracle Instant Client
RUN wget https://download.oracle.com/otn_software/linux/instantclient/199000/instantclient-basic-linux.x64-19.9.0.0.0dbru.zip -O /tmp/instantclient.zip && \
unzip /tmp/instantclient.zip -d /usr/lib/instantclient && \
rm /tmp/instantclient.zip
#Install Oracle SDK
RUN wget https://download.oracle.com/otn_software/linux/instantclient/199000/instantclient-sdk-linux.x64-19.9.0.0.0dbru.zip -O /tmp/instantclient-sdk-linux.x64-19.9.0.0.0.zip && \
unzip /tmp/instantclient-sdk-linux.x64-19.9.0.0.0.zip -d /usr/lib/ && \
rm /tmp/instantclient-sdk-linux.x64-19.9.0.0.0.zip
#Install Oracle Tools through SQLPlus
RUN wget https://download.oracle.com/otn_software/linux/instantclient/199000/instantclient-sqlplus-linux.x64-19.9.0.0.0dbru.zip -O /tmp/instantclient-sqlplus-linux.x64-19.9.0.0.0.zip && \
unzip /tmp/instantclient-sqlplus-linux.x64-19.9.0.0.0.zip -d /usr/lib/ && \
rm /tmp/instantclient-sqlplus-linux.x64-19.9.0.0.0.zip
WORKDIR /app
COPY --from=builder /app/cmd/svr .
EXPOSE 8000
CMD ["./app"]
Again this is how i solved the problem for a Golang API. There may be others that solved the Alpine issue but i was never able to get it to work, even using older version of the Oracle Instant Client.
Try this Docker file. Start from the basic alpine linux image and add the required packages.
FROM alpine:3.13
WORKDIR /project
RUN wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-basiclite-linux.x64-21.1.0.0.0.zip -qO- | busybox unzip -q - && \
wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-sqlplus-linux.x64-21.1.0.0.0.zip -qO- | busybox unzip -q - && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.33-r0/glibc-2.33-r0.apk -q
RUN apk add --allow-untrusted libaio glibc-2.33-r0.apk
RUN cd instantclient_21_1 && cp /usr/lib/libaio.so.1 /lib/libc.musl-x86_64.so.1 . && chmod +x sqlplus
ENV LD_LIBRARY_PATH=/project/instantclient_21_1
[Fri Jul 27 03:08:18.935217 2018] [:error] [pid 11] [client 172.18.0.1:54146] PHP Fatal error: Cannot redeclare CreateUniqeSlugOfuser() (previously declared in /var/www/public_html/livesite/application/helpers/MY_url_helper.php:111) in /var/www/public_html/livesite/application/helpers/my_url_helper.php on line 111
Above is the error, I thought maybe this was a simple rename the file in my directory to MY_url_helper with the uppercase but this did not fix the error as some sites have said. As it stands I have no idea how to fix this but I do have some clues.
I'm not a code igniter expert, I took on this project from another developer, but it currently works on their server. It does not work on my server however. Seeing as the issue is probably with autoloading, what could be the thing I'm doing wrong? Could a different version in PHP be causing this issue?
Another hunch is maybe it's some cache I have to change? I'm not sure though... any ideas are appreciated.
I will say after changing the file name the error still thinks I'm using the lowercase version? I know it's reading the file cause I can throw phpinfo in the file and it seems to trigger hence the image I uploaded as a result of that.
Update:: Did echo CI_VERSION command to find this (2.2.0). Maybe this version is not compatible with PHP 7.0?
php56 is for sure the version on the other server... I will see if I can get a docker image of this somehow.
Well 5.6 still error.
Dockerfile
FROM php:5.6-apache
MAINTAINER Joe Astrahan <jastrahan#poolservice.software>
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y \
bzip2 curl git less mysql-client sudo unzip zip \
libbz2-dev libfontconfig1 libfontconfig1-dev \
libfreetype6-dev libjpeg62-turbo-dev libpng-dev libzip-dev && \
rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install bz2 && \
docker-php-ext-configure gd \
--with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd && \
docker-php-ext-install iconv && \
docker-php-ext-install opcache && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install zip
RUN curl -sS https://getcomposer.org/installer \
| php -- --install-dir=/usr/local/bin --filename=composer
# Set environment variables for Apache so we know its user and group names
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
# Configure Apache SSL and Standard Virtualhosts
COPY config/apache_default.conf /etc/apache2/sites-available/000-default.conf
COPY config/apache_default-ssl.conf /etc/apache2/sites-available/default-ssl.conf
COPY config/run /usr/local/bin/run
# Configure SSL Directories & Create Temporary SSL Keys
RUN mkdir /etc/apache2/ssl
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt -subj "/C=US/ST=Florida/L=Fort Lauderdale/O=Pool Service Software LLC/OU=IT Department/CN=dev.poolservice.software.local"
RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite
#Configure SSL On Apache2 & Headers Mod
RUN a2enmod ssl
RUN a2enmod headers
RUN service apache2 restart
RUN a2ensite default-ssl.conf
RUN service apache2 restart
#Install Zip & Unzip
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install zip unzip -y
#Install NodeJS
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
software-properties-common
EXPOSE 80
EXPOSE 443
CMD ["/usr/local/bin/run"]
Maybe you already loaded the helper either in autoload or a class that was initialized before you attempted to load it again. CI is able to prevent duplicates with classes but not pure php helper files. That is why they surround their functions with:
if (!function_exists('functionname')) { ... }
I would suggest you do the same.
So I solved the issue. Turns out PHP version didn't really make a difference, my docker file was changed to PHP 7.0 since it worked with that, I'll attach it below.
It turns out that CodeIgniter 2.x was using mysql instead of mysqli, so I changed all references in the code accordingly. Also I had to rename the file my_url_helper to just urlhelper_helper and then in the autoload file change it accordingly so it would load the correct file. For some reason even though it worked on the old server, I had to do this to get it to work with either version of PHP.
These fixes were all that were necessary to fix it.
I have a php application in Github, and I want to create a Docker image to, automaticaly, clone this application and run a custom server php file (react-php implemented).
This is my point of start.
FROM php:7.1-cli
RUN apt-get update && \
apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip bcmath
RUN apt-get install -y \
git-core \
curl && \
git clone https://github.com/xxx/xxx.git myfolder && \
cd myfolder && \
curl -sS https://getcomposer.org/installer | php && \
php composer.phar install
EXPOSE 8000
CMD ["php bin/server"]
This code allows me to build the image, but when I run this image in a container, then I'm not being able to execute the file.
/usr/local/bin/docker-php-entrypoint: 9: exec: php bin/server: not
found
Maybe it's because I don't barely understand some bases of Docker, but it's getting hard for me to make this happen.
Any help on that, please?
According to the official docker documentation for CMD, you should try to modify the last line of your Dockerfile to either CMD php bin/server or CMD ["php", "bin/server"]
Furthermore if you want your commands to be executed with a relative path, you should consider setting the working directory with the WORKDIR directory command before using RUN, CMD, ENTRYPOINT, COPY or ADD.
I'm having issues trying to install and enable the PHP soap extension. I'm running the base image php:7.2-fpm-alpine3.6 inside a Docker container that has instructions like below in the Dockerfile. It's unclear to me how extensions are installed on Alpine. It seems to use docker-php-ext-install from what I can infer.
Dockerfile (I adopted this from somewhere):
RUN apk --no-cache add \
freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev \
wget \
git \
nginx \
ca-certificates \
supervisor \
bash \
nano \
&& docker-php-ext-install \
mysqli \
pdo_mysql \
opcache \
...
So, I tried
docker-php-ext-install soap
which told me configure: error: xml2-config not found. Please check your libxml2 installation. I tried a bunch of stuff, but
apk add --no-cache libxml2-dev
seemed to do something. I followed this again with docker-php-ext-install soap, which outputted
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la modules/* libs/*
At this point, I did not run make test, as it's unclear where I'm suppose to go find this Makefile. I searched under /usr/local/lib/php/extensions/no-debug-non-zts-20170718/, and soap.so was already there. Furthermore, my commands already enabled it for PHP-FPM. php -i showed /usr/local/etc/php/conf.d/docker-php-ext-soap.ini,.
I'm not entirely sure what I did. Is this (docker-php-ext-install) how you install extensions on this OS?
The PHP SOAP extension requires the PHP XML extension, as documented here: http://php.net/manual/en/soap.requirements.php
I expect you need to install that first.
Presumably docker-php-ext-install xml.
You shouldn't need to compile the XML library yourself as it will be part of the extension.
The solution is:
RUN set -ex && apk --no-cache add libxml2-dev
RUN docker-php-ext-install soap
You can add a utility to your image using this package
Example:
FROM php:7.2-cli
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions gd xdebug
If you want, you can remove the last line and enter the container to play around with adding packages.
docker exec -it <container_id> bash # (swap bash for sh if using alpine)
Then you can just type install-php-extensions <ext>
Not every alpine distribution contains docker-php-ext commands etc, and I don't know how to add them easily, it did not look simple at all to me.
Anyway, any php extension can be easily installed by issuing this alpine install command
to find any php extension
apk search -v 'php' |grep ldap
result
phpldapadmin-1.2.3-r4 - Web front-end for managing OpenLDAP
php7-ldap-7.2.22-r0 - PHP7 extension: LDAP
php5-ldap-5.6.40-r0 - ldap extension for PHP
to further install the extension, one must supply its name in a form without the suffix version part , eg. without -7.2.22-r0 in php7-ldap-7.2.22-r0 so it's php7-ldap
like this
apk install php7-ldap
I'm able to upgrade the cURL binary and libs, however PHP still utilizes the old version.
I'm building on top of the official php:7.0-fpm docker container.
First, I've upgraded cURL:
RUN curl -fsSL 'https://curl.haxx.se/download/curl-7.50.3.tar.gz' -o curl.tar.gz \
&& mkdir -p curl \
&& tar -xf curl.tar.gz -C curl --strip-components=1 \
&& rm curl.tar.gz \
&& ( \
cd curl \
&& make \
&& make install \
&& ldconfig \
) \
&& rm -r curl
I've tried:
Use libtool
cd curl \
&& ./buildconf \
&& ./configure \
# ...
Re-install curl for PHP
RUN docker-php-ext-configure curl --with-curl=/usr/local/lib
RUN docker-php-ext-install curl
But this throws the error/warning:
warning: curl (curl.so) is already loaded!
and eventually just ignores that I want to reinstall it.
Several smaller random stuff
If possible, I'm looking for a solution that doesn't require a complete recompile of PHP.