-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
69 lines (54 loc) · 2.12 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
69
FROM apache/spark:3.5.1 as python-base
USER root
ENV PYTHONUNBUFFERED=1 \
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"
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
build-essential \
libpq-dev \
zip \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
python3.11 \
python3.11-venv \
python3.11-dev \
python3-pip
# Ensure 'python' command points to 'python3.11'
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 \
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
##########################################################################################
# builder-base is used to build dependencies
FROM python-base as builder-base
# Install Poetry - respects $POETRY_VERSION & $POETRY_HOME
ENV POETRY_VERSION=1.8.3
RUN curl -sSL https://install.python-poetry.org | python3 -
# 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 --without dev --no-root
# Copy the pe_analyzer directory and zip it
COPY ./pe_analyzer /pe_analyzer
COPY ./scripts /scripts
RUN zip -r /pe_analyzer.zip /pe_analyzer
##########################################################################################
FROM python-base as production
COPY --from=builder-base $VENV_PATH $VENV_PATH
COPY --from=builder-base /pe_analyzer.zip /service/pe_analyzer.zip
COPY --from=builder-base /scripts /service/scripts
COPY . /service/
WORKDIR /service
RUN /usr/bin/python3.11 --version
ENTRYPOINT ["bash", "/service/scripts/entrypoint.sh"]