I want to deploy to Azure python scripts will use the Selenium library to do some automated testing against various websites at certain hours of the day.
I want to use Docker with Azure.
My current thinking is that I have to develop a docker compose script to:
- deploy a Selenium standalone chrome image listening on port 4444.
- deploy another container with some Python image and have my Python scripts in there running with CRON
- because I have 2 containers that don't know about each other I think I have to run a docker command to set up a network so these 2 containers can talk to each other. Does this go in the docker-compose script?
As you can tell I am a bit new to all of this - so is my thinking right or have I made it too complicated?
CodePudding user response:
I think all of this could be done in a single container. I think both ways are doable, but you are right in thinking that the compose file will need the network definition.
As an example:
FROM python:3.8
COPY . /app
WORKDIR /app
RUN mkdir __logger
# install google chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable
# install chromedriver
RUN apt-get install -yqq unzip
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
# set display port to avoid crash
ENV DISPLAY=:99
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
CMD ["python", "./app.py"]