Docker: Dockerfile: TestAuto with JRE8, php7.2, and a PHPUnit Selenium TestFramework

Dockerfile draft for creating an image for a Test Automation framework using PHPUnit, phpwebdriver, & selenium-server.jar

DockerPayload

Composer install recommends NOT installing as root. StackOverflow had the following recommendation:

RUN chmod u+s /usr/sbin/php-fpm7

USER deploy
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm7","-F"]

using sed to replace strings in text files without a text editor

sed 's/sedtest/seedtest/' sedtest.txt > seedtest.txt && mv seedtest.txt sedtest.txt
  • s = substitute
  • find = sedtest
  • replace with = seedtest
  • sed won't alter the source file, but a destination file can be specified
  • if one wants to effectively update the SOURCE file, simply append the command with 'mv'

# source image
FROM ubuntu

#Prevent superflous cli prompts
ENV DEBIAN_FRONTEND=noninteractive

#Update APT
RUN apt-get update

#Install unzip
RUN apt-get install unzip zip

#Install net-tools  - netstat, etc
RUN apt-get install -y net-tools

#Install GIT
RUN apt-get install -y git

# JAVA -------------------
#Add JAVA repo
RUN apt-get install -y curl software-properties-common
RUN add-apt-repository ppa:webupd8team/java

#Install Java
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
RUN echo devconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
RUN apt-get update && apt-get -y install oracle-java8-installer
RUN apt-get update && apt-get -y install oracle-java8-set-default
ENV JAVA_OPTS -server -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC \
   -Xms1G -Xmx2G -XX:PermSize=1G -XX:MaxPermSize=2G
# JAVA -------------------

#PHP7.2-------------
#RUN apt-get install python-software-properties # fails, superceded by software-properties-common?
RUN add-apt-repository ppa:ondrej/php
RUN apt-get update
RUN apt-get install -y -q php7.2
RUN apt-cache search --names-only ^php
RUN apt-get install -y php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml php7.2-bz
#sudo apt-get --purge autoremove -y
RUN rm /etc/php/7.2/cli/php.ini
COPY php.ini /etc/php/7.2/cli/php.ini
#PHP7.2-------------

#Composer runtim & phpwebdriver json
#COPY composer.phar
#COPY composer.json


#TestAuto------------

RUN mkdir /var/www/tools
RUN mkdir /var/www/tools/selenium-server
RUN mkdir /var/www/tools/phantomjs
RUN mkdir /var/blackboxtest

COPY phpunitwebdriver.tar.gz /var/blackboxtest
RUN cd /var/blackboxtest && tar -xvf phpunitwebdriver.tar.gz && php composer.phar install
RUN chmod +x /var/blackboxtest/bin/selenium/server/selenium-server-standalone-3.9.1.jar
#RUN java -jar /var/blackboxtest/bin/selenium/server/selenium-server-standalone-3.9.1.jar & disown

WORKDIR /var/blackboxtest
#TestAuto ------------

#--------------
# NOT USED
#--------------

#Install a composer project
#CMD ["php","composer.phar", "install"] #container immediately exits after install with CMD

# Install Tomcat
#RUN mkdir -p /opt/tomcat
#RUN curl -SL http://apache.mirror.gtcomm.net/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz | \
# tar -xzC /opt/tomcat --strip-components=1
#RUN rm -Rf /opt/tomcat/webapps/docs /opt/tomcat/webapps/examples
#RUN apt-get --purge autoremove -y
#RUN apt-get clean
#COPY tomcat-users.xml /opt/tomcat/conf/
# Expose Tomcat
#EXPOSE 8080
#WORKDIR /opt/tomcat
#CMD ["bin/catalina.sh","run"]

#ENV TZ=Europe/Minsk
#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#RUN apt update && apt instal..

#--------------
# NOT USED
#--------------