I want to get chrome to work headless with selenium on an ubuntu server so that I can run tests against it.
here's the commands I ran to set up chrome headless using xvfb.
Am I missing anything?
apt-get update && apt-get upgrade
apt-get install -y libxss1 libappindicator1 libindicator7 unzip
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
sudo apt-get install -y xvfb xfonts-100dpi xfonts-75dpi xfonts-cyrillic xorg dbus-x11
wget -N http://chromedriver.storage.googleapis.com/2.24/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod 755 chromedriver
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
sudo apt-get install -y python-pip libosmesa6
sudo apt-get update && sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic xvfb x11-apps imagemagick firefox google-chrome-stable
pip install pyvirtualdisplay selenium
sudo apt-get install firefox -y
useradd -m jenkins-user
mkdir /home/jenkins-user/log
chown jenkins-user:root /home/jenkins-user/log
sudo apt-get install -y default-jdk
apt-get install -y git
iptables -N SELENIUM
iptables -A INPUT -p tcp --dport 4444 -j SELENIUM
iptables -A SELENIUM -p tcp --dport 4444 -s 127.0.0.1 -j ACCEPT
iptables -A SELENIUM -p tcp --dport 4444 -j DROP
apt-get install jq
Here is a snippet from where I create my driver instance.
This is working on my mac, but have not tested this on ubuntu yet. I'll be doing that very soon.
Note the option: --disable-gpu. This is what made it to work on my local machine.
System.setProperty("webdriver.chrome.driver", chromeAbsolutePath + "");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
options.addArguments("--headless");
options.addArguments("--disable-gpu");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("acceptInsecureCerts", false);
capabilities.setCapability("acceptSslCerts", false);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(capabilities);
System.out.println(BROWSER + " on local machine initiated");
Related
I have an app that I use to connect to a sql server database. The app run smoothly on my local machine. I created a docker container for the app. In the past the app was working properly but now after re-building the container the app fails to connect to the sql server when deployed using the container. locally it still connects.
I thought it has to do with some library versions but I made sure the requirments.txt has the same versions I have installed locally.
any idea what else it could be?
This is my dockerfile
FROM python:3.9.7
RUN apt update && apt-get update
# RUN apt install odbcinst1debian2 libodbc1 odbcinst unixodbc unixodbc-dev -y
RUN wget --no-check-certificate http://ftp.us.debian.org/debian/pool/main/u/unixodbc/libodbc1_2.3.9-5_amd64.deb
RUN wget --no-check-certificate http://ftp.us.debian.org/debian/pool/main/u/unixodbc/libodbc2_2.3.9-5_amd64.deb
RUN wget --no-check-certificate http://ftp.us.debian.org/debian/pool/main/u/unixodbc/libodbccr2_2.3.9-5_amd64.deb
RUN wget --no-check-certificate http://http.us.debian.org/debian/pool/main/u/unixodbc/odbcinst_2.3.9-5_amd64.deb
RUN wget --no-check-certificate http://http.us.debian.org/debian/pool/main/u/unixodbc/odbcinst1debian2_2.3.9-5_amd64.deb
RUN wget --no-check-certificate http://ftp.us.debian.org/debian/pool/main/u/unixodbc/unixodbc_2.3.9-5_amd64.deb
RUN wget --no-check-certificate http://http.us.debian.org/debian/pool/main/u/unixodbc/unixodbc-dev_2.3.9-5_amd64.deb
RUN wget --no-check-certificate http://http.us.debian.org/debian/pool/main/u/unixodbc/unixodbc-common_2.3.9-5_all.deb
RUN wget --no-check-certificate http://http.us.debian.org/debian/pool/main/u/unixodbc/libodbcinst2_2.3.9-5_amd64.deb
RUN dpkg -i libodbc2_2.3.9-5_amd64.deb
RUN dpkg -i libodbccr2_2.3.9-5_amd64.deb
RUN dpkg -i libodbc1_2.3.9-5_amd64.deb
RUN dpkg -i unixodbc-common_2.3.9-5_all.deb
RUN dpkg -i libodbcinst2_2.3.9-5_amd64.deb
RUN dpkg -i odbcinst_2.3.9-5_amd64.deb
RUN dpkg -i odbcinst1debian2_2.3.9-5_amd64.deb
RUN dpkg -i unixodbc_2.3.9-5_amd64.deb
RUN dpkg -i unixodbc-dev_2.3.9-5_amd64.deb
RUN pip install --proxy=http://PITC-Zscaler-Americas-Houston.proxy.bakerhughes.com:80 --upgrade pip
COPY requirements.txt requirements.txt
RUN pip3 install --trusted-host bhihoutfsnuget --index-url https://bhihoutfsnuget/pypi/PyPi/simple -r requirements.txt
RUN apt-get update && apt-get install -y gnupg
# RUN apt install gnupg
RUN mkdir /app
RUN wget --no-check-certificate https://dev.mysql.com/get/Downloads/Connector-ODBC/8.0/mysql-connector-odbc_8.0.26-1debian10_amd64.deb
RUN wget --no-check-certificate https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-plugins_8.0.26-1debian10_amd64.deb
RUN dpkg -i mysql-community-client-plugins_8.0.26-1debian10_amd64.deb
RUN dpkg -i mysql-connector-odbc_8.0.26-1debian10_amd64.deb
RUN rm -rf mysql-connector-odbc_8.0.26-1debian10_amd64.deb
RUN rm -rf mysql-community-client-plugins_8.0.26-1debian10_amd64.deb
RUN rm -rf libodbc2_2.3.9-5_amd64.deb
RUN rm -rf libodbccr2_2.3.9-5_amd64.deb
RUN rm -rf libodbc1_2.3.9-5_amd64.deb
RUN rm -rf unixodbc-common_2.3.9-5_all.deb
RUN rm -rf libodbcinst2_2.3.9-5_amd64.deb
RUN rm -rf odbcinst_2.3.9-5_amd64.deb
RUN rm -rf odbcinst1debian2_2.3.9-5_amd64.deb
RUN rm -rf unixodbc_2.3.9-5_amd64.deb
RUN rm -rf unixodbc-dev_2.3.9-5_amd64.deb
COPY ./v2 /app
WORKDIR /app
CMD ["python","main.py"]
I am trying to install mysql-server in debian:buster using Dockerfile and shell script, when I run this command
apt install -y mysql-server and during the installation I need to enter the password and retype it as shown in the picture:
I did a little search and I found how to do it using here-string in this page Install MySQL on Ubuntu without a password prompt
so because I am using this command apt install -y mysql-server I did it like this:
debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
apt-get -y install mysql-server
but when I run them I still get the same thing and I need to enter the password.
Here is my Dockerfile:
From debian:buster
COPY ./run.sh /
CMD bash /run.sh
and this is run.sh:
apt update
apt install -y nginx gnupg wget lsb-release
wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
printf "1\n1\n4\n" | dpkg -i mysql-apt-config_0.8.13-1_all.deb //version selected is mysql-5.7
apt update
service nginx start
bash //just to stay in the bash of container and don't quit from it.
by the way I am trying to install mysql-server from inside the bash of the container then I'll write the commands in my script.
and there is something weird as you can see in the picture above it's written :
Configuring mysql-community-server
----------------------------------
even that I am installing with this command apt-get -y install mysql-server not this
apt-get -y install mysql-community-server
So do you know what am I missing here?
Use
shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password mypassword"
shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password mypassword"
shell> sudo DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server
Documentation
With 2.6.2, ansible started ignoring config files in world writable dirs, rendering many windows/vagrant setups useless. I try to install Ansible 2.6 or older.
System:
Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-132-generic x86_64)
The propvision.sh states
# Add Ansible Repository & Install Ansible
sudo add-apt-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible && sudo touch /root/ansible_ready
I adapted it to
sudo apt-get install -y ansible=2.6.0 && sudo touch /root/ansible_ready
^^^^^^
but that version was not found. How can I obtain 2.5 or 2.6? I am quite unexperienced with linux and the concept of installing something not by a doubleclick.
For installation of Ansible version 2.6 on Trusty Tahr 14.04 (LTS), proceed with the follow commands:
sudo apt update
sudo apt install -y software-properties-common
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
Add apt source list:
sudo tee -a /etc/apt/sources.list.d/ansible-2.6.list << EOF
deb http://ppa.launchpad.net/ansible/ansible-2.6/ubuntu trusty main
deb-src http://ppa.launchpad.net/ansible/ansible-2.6/ubuntu trusty main
EOF
Update apt and install Ansible:
sudo apt update
sudo apt install -y ansible
It is my first time working with docker. I want to create a remote container with test environment for my java application. I also need mysql database. Everything should run on one container (it's a requirement, not my idea).
I need to have a db initiated with .sql file (let's say file.sql located in the same directory as Dockerfile)
Thank you very much for help :)
Here is part of my Dockerfile:
FROM ubuntu:16.04
#Install JRE
RUN apt-get update && apt-get install default-jre -y
#Install JDK
RUN apt-get update && apt-get install default-jdk -y
#Install Maven
RUN apt-get update && apt-get install maven -y
#Install wget
RUN apt-get update && apt-get install wget -y
#\&& rm -rf /var/lib/apt/lists/*
#Install unzip
RUN apt-get update && apt-get install unzip -y
#Install glassfish
RUN mkdir -p /opt && cd opt/
RUN wget http://download.java.net/glassfish/4.1.1/release/glassfish-4.1.1.zip
RUN unzip glassfish-4.1.1.zip
#Install mysql
ENV MYSQL_USER=mysql\ MYSQL_DATA_DIR=/var/lib/mysql \ MYSQL_RUN_DIR=/run/mysqld \ MYSQL_LOG_DIR=/var/log/mysql
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server \&& rm -rf ${MYSQL_DATA_DIR} \&& rm -rf /var/lib/apt/lists/*
First use a ADD to copy your .sql file in the image. Then add a RUN command to restore your DB using mysql commands.
Thank you all for answers!
I found a sollution if anyone will encouter the same problem it's here:
RUN echo "mysql-server mysql-server/root_password password password" | debconf-set-selections
RUN echo "mysql-server mysql-server/root_password_again password password" | debconf-set-selections
RUN apt-get update && apt-get -y install mysql-server && service mysql start
if mysql is still not starting check /etc/docker/daemon.json, make sure it looks like this:
{
"storage-driver":"overlay2"
}
if you don't have this file execute:
mkdir -p /etc/docker
echo '{"storage-driver":"overlay2"}' > /etc/docker/daemon.json
systemctl restart docker.service
I am trying to compose my custom Dockerfile for setting up Mysql 5.7.
As part of this I would like to set s3 backup as well.
But when I try to run/create the docker instance it fails
Here is the Dockerfile:
# Start with a base mysql:5.6 image
FROM mysql:5.7
MAINTAINER Ikenna N. Okpala <me#ikennaokpala.com>
USER root
# RUN locale-gen
ENV DEBIAN_FRONTEND noninteractive
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.en
ENV LC_ALL en_US.UTF-8
ENV PS_NGX_EXTRA_FLAGS --with-cc=/usr/bin/gcc --with-ld-opt=-static-libstdc++
# Add all base dependencies
RUN apt-get update -y
RUN apt-get install -y build-essential checkinstall
RUN apt-get install -y vim curl wget unzip
RUN apt-get install -y libfuse-dev libcurl4-openssl-dev mime-support automake libtool python-docutils libreadline-dev
RUN apt-get install -y pkg-config libssl-dev
RUN apt-get install -y git-core
RUN apt-get install -y man cron
RUN apt-get install -y libgmp-dev
RUN apt-get install -y zlib1g-dev
RUN apt-get install -y libxslt-dev
RUN apt-get install -y libxml2-dev
RUN apt-get install -y libpcre3 libpcre3-dev
RUN apt-get install -y freetds-dev
# RUN apt-get install -y openjdk-7-jdk
RUN apt-get install -y software-properties-common
RUN mkdir -p /mnt/s3b
RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
RUN cd ~/
RUN /bin/bash -l -c "wget https://github.com/s3fs-fuse/s3fs-fuse/archive/master.zip"
RUN unzip master.zip
RUN cd s3fs-fuse-master/ && ./autogen.sh && ./configure --prefix=/usr --with-openssl && make && make install
ADD templates/setup.sh /root/setup.sh
RUN chmod +x /root/setup.sh
ADD templates/backup-cron /etc/cron.d/backup-cron
RUN chmod 0644 /etc/cron.d/backup-cron
RUN cron
# RUN chmod +x /root/backup-cron
EXPOSE 3306
CMD ["/bin/bash", "-l", "-c", "/root/setup.sh"]
Here is the setup.sh file
#!/bin/bash
export MYSQL_HOST_IP=`awk 'NR==1 {print $1}' /etc/hosts`
set -e
set -x
# NOW=$(date +"%Y-%m-%d-%H%M")
# DUMP_FILE="/dumps/dump.sql"
echo $AWS_S3 >> ~/.passwd-s3fs && cp ~/.passwd-s3fs /etc/passwd-s3fs
chmod 600 ~/.passwd-s3fs
chmod 640 /etc/passwd-s3fs
mysql -h$MYSQL_HOST_IP -uroot -p$MYSQL_ROOT_PASSWORD -e "DROP DATABASE IF EXISTS $MYSQL_DATABASE; CREATE USER '$MYSQL_USER'#'localhost' IDENTIFIED BY '$MYSQL_PASSWORD'; CREATE DATABASE $MYSQL_DATABASE; GRANT ALL ON $MYSQL_DATABASE.* TO '$MYSQL_USER'#'localhost'; FLUSH PRIVILEGES;"
Here is the docker run command:
docker run --name=mysql-s3 --env MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} --env MYSQL_USER=${MYSQL_USER} --env MYSQL_PASSWORD=${MYSQL_PASSWORD} --env MYSQL_DATABASE=${MYSQL_DATABASE} --env AWS_S3=${AWS_S3} --detach --publish 3306:3306 --volume=/vagrant/scripts/dumps/:/dumps/ --cap-add mknod --cap-add sys_admin --device=/dev/fuse --privileged mysql-s3
This approach seems too complicated using fuse and modifying the base mysql container. I would suggest that you just stick with the base MYSQL and write a script that you run in a separate container that does a MYSQL dump to a text file and then copies that text file to S3 with the AWS CLI.