forked from mordax7/flathunter
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from codders/feat/google-cloud-run
Dockerfile and script for running crawl jobs in Google Cloud Run with captcha support
- Loading branch information
Showing
21 changed files
with
437 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM python:3.7 | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ARG PIP_NO_CACHE_DIR=1 | ||
|
||
# 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 | ||
|
||
# Copy files | ||
WORKDIR /usr/src/app | ||
COPY . . | ||
|
||
# Upgrade pip, install pipenv | ||
RUN pip install --upgrade pip | ||
|
||
# Generate requirements.txt and install dependencies from there | ||
RUN pip install -r requirements.txt | ||
|
||
RUN python chrome_driver_install.py | ||
|
||
CMD python cloud_job.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import logging | ||
import os | ||
|
||
from flathunter.logging import wdm_logger | ||
from webdriver_manager.chrome import ChromeDriverManager | ||
|
||
# Cache the driver manager to local folder so that gunicorn can find it | ||
os.environ['WDM_LOCAL'] = '1' | ||
wdm_logger.setLevel(logging.INFO) | ||
|
||
ChromeDriverManager().install() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" Startup file for Google Cloud deployment or local webserver""" | ||
import logging | ||
import os | ||
|
||
from flathunter.googlecloud_idmaintainer import GoogleCloudIdMaintainer | ||
from flathunter.web_hunter import WebHunter | ||
from flathunter.config import Config | ||
from flathunter.logging import logger, wdm_logger, configure_logging | ||
|
||
from flathunter.web import app | ||
|
||
config = Config() | ||
|
||
# Load the driver manager from local cache (if chrome_driver_install.py has been run | ||
os.environ['WDM_LOCAL'] = '1' | ||
# Use Google Cloud DB if we run on the cloud | ||
id_watch = GoogleCloudIdMaintainer() | ||
|
||
configure_logging(config) | ||
|
||
# initialize search plugins for config | ||
config.init_searchers() | ||
|
||
hunter = WebHunter(config, id_watch) | ||
|
||
hunter.hunt_flats() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
steps: | ||
# Build the container image | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: ['build', '-t', 'gcr.io/flathunters/flathunter-job', '-f', 'Dockerfile.gcloud.job', '.'] | ||
# Push the container image to Container Registry | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: ['push', 'gcr.io/flathunters/flathunter-job'] | ||
images: | ||
- gcr.io/flathunters/flathunter-job | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.