Estoy tratando de desplegar un pequeño script pitón usando Selenio en mi máquina virtual de GCP siguiendo este tutorial. Desafortunadamente, no puedo pasar el requirements.txt
al construir la imagen del contenedor. De hecho, como se puede leer:
mikempc3@instance-1:~$ sudo docker pull python:3.7-slim
3.7-slim: Pulling from library/python
6ec8c9369e08: Already exists
401b5acb42e6: Already exists
2e487de6656a: Pull complete
519de614852e: Pull complete
a3d1a61e090c: Pull complete
Digest: sha256:47081c7bca01b314e26c64d777970d46b2ad7049601a6f702d424881af9f2738
Status: Downloaded newer image for python:3.7-slim
docker.io/library/python:3.7-slim
mikempc3@instance-1:~$ sudo docker build --tag my-python-app:1 .
Sending build context to Docker daemon 387.1MB
Step 1/6 : FROM python:python3.7-slim
manifest for python:python3.7-slim not found: manifest unknown: manifest unknown
mikempc3@instance-1:~$ sudo docker build --tag my-python-app:1 .
Sending build context to Docker daemon 387.1MB
Step 1/6 : FROM python:python3.7-slim
manifest for python:python3.7-slim not found: manifest unknown: manifest unknown
Aquí está mi archivo requirements.txt:
selenium
pandas
numpy
requests
Y aquí está el archivo que estoy tratando de contener:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import ElementClickInterceptedException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.chrome.options import Options
import pandas as pd
import numpy as np
from collections import defaultdict
import json
import time
import requests
from requests.exceptions import ConnectionError
# Define Browser Options
chrome_options = Options()
chrome_options.add_argument("--headless") # Hides the browser window
# Reference the local Chromedriver instance
chrome_path = r"C:Programschromedriver.exe"
driver = webdriver.Chrome(executable_path=chrome_path, options=chrome_options)
df = pd.read_csv('path/to/file')
tradable = ()
print(len(df('Ticker')))
for ticker in df('Ticker'):
print("ticker: ", ticker)
location = "https://www.etoro.com/markets/" + ticker.lower()
try:
request = requests.get(location)
driver.get(location)
time.sleep(2)
current_url = driver.current_url
if current_url == location:
tradable.append(ticker)
else:
print("no page but request= ", request)
except ConnectionError:
print('Ticker isn't tradable')
else:
tradable.append(ticker)
Aquí está mi Dockerfile:
FROM python:python3.7-slim
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
CMD python ./find_tradable.py
Aquí están mi nombre y mi versión:
mikempc3@instance-1:~$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Aquí está mi versión del núcleo de Linux:
mikempc3@instance-1:~$ uname -r
4.9.0-12-amd64