-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
68 lines (55 loc) · 2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
FROM python:3.7 as base
LABEL maintainer="Espy Mur.. f{}@{}.format(espoir.mur, gmail)"
# Never prompt the user for choices on installation/configuration of packages
ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONUNBUFFERED=1 \
PORT=8080 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"\
PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
FROM base AS python-deps
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
curl \
build-essential\
software-properties-common
# Install Poetry - respects $POETRY_VERSION & $POETRY_HOME
ENV POETRY_VERSION=1.1.8
RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
# We copy our Python requirements here to cache them
# and install only runtime deps using poetry
WORKDIR $PYSETUP_PATH
COPY ./poetry.lock ./pyproject.toml ./
RUN poetry install --no-dev # respects
FROM base AS runtime
COPY --from=python-deps $POETRY_HOME $POETRY_HOME
COPY --from=python-deps $PYSETUP_PATH $PYSETUP_PATH
RUN useradd --create-home es.py
RUN mkdir /home/es.py/scrapers
ENV WORKING_DIR=/home/es.py/scrapers
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:${WORKING_DIR}:$PATH"
ENV PYTHONPATH="${PYTHONPATH}:${WORKING_DIR}"
WORKDIR ${WORKING_DIR}
RUN chown -R es.py:es.py ${WORKING_DIR}
RUN chmod -R 755 ${WORKING_DIR}
RUN chown -R es.py:es.py "/opt/"
RUN chmod -R 755 "/opt/"
COPY src ${WORKING_DIR}/src
RUN mkdir ${WORKING_DIR}/logs
RUN chown -R es.py:es.py "${WORKING_DIR}/logs/"
RUN chmod -R 755 "${WORKING_DIR}/logs/"
COPY config.py ${WORKING_DIR}
COPY scrapy.cfg ${WORKING_DIR}
COPY scrapydweb_settings_v10.py ${WORKING_DIR}
COPY docker-entrypoint.sh ${WORKING_DIR}
USER es.py
EXPOSE 6800 5000 5555
ENTRYPOINT [ "/bin/sh","-c" ]