Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Dockerize crawler

Michal Filippi20b58d15ce10
diff --git a/Dockerfile.crawler b/Dockerfile.crawler
new file mode 100644
index 0000000..4877a5c
--- /dev/null
+++ b/Dockerfile.crawler
@@ -0,0 +1,37 @@
+FROM python:3.10.2-bullseye AS base
+
+ENV PYTHONFAULTHANDLER=1 \
+ PYTHONHASHSEED=random \
+ PYTHONUNBUFFERED=1
+
+WORKDIR /app
+
+FROM base AS builder
+
+ENV PIP_DEFAULT_TIMEOUT=100 \
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
+ PIP_NO_CACHE_DIR=1 \
+ POETRY_VERSION=1.1.12
+
+
+# Create a /venv directory & environment.
+# This directory will be copied into the final stage of docker build.
+RUN python -m venv /venv
+
+# Copy only the necessary files to build/install the python package
+COPY pyproject.toml poetry.lock /app/
+COPY mwmbl /app/mwmbl
+
+# Working directory is /app
+# Use pip to install the mwmbl python package
+# PEP 518, PEP 517 and others have allowed for a standardized python packaging API, which allows
+# pip to be able to install poetry packages.
+RUN /venv/bin/pip install pip wheel --upgrade && \
+ /venv/bin/pip install .
+
+FROM base AS final
+
+# Copy only the required /venv directory from the builder image that contains mwmbl and its dependencies
+COPY --from=builder /venv /venv
+
+CMD ["/venv/bin/mwmbl-crawl"]