|
1 | | -FROM python:3.12-alpine AS sentinela |
| 1 | +ARG PYTHON_VERSION=3.12 |
2 | 2 |
|
| 3 | +# Base image |
| 4 | +FROM python:${PYTHON_VERSION}-alpine AS base |
| 5 | + |
| 6 | +ARG SENTINELA_PLUGINS |
3 | 7 | ENV VIRTUAL_ENV=/opt/venv \ |
4 | 8 | PATH="/opt/venv/bin:$PATH" |
5 | 9 |
|
6 | 10 | WORKDIR /app |
| 11 | +COPY . /app/ |
7 | 12 |
|
8 | 13 | RUN python3 -m venv $VIRTUAL_ENV \ |
9 | | - && pip install --upgrade pip \ |
10 | | - && pip install poetry --no-cache-dir |
| 14 | + && pip install --no-cache-dir --upgrade pip \ |
| 15 | + && pip install poetry --no-cache-dir \ |
| 16 | + && poetry install --only $(python ./tools/get_plugins_list.py) \ |
| 17 | + && find . -type d -name __pycache__ | xargs -n1 rm -r |
11 | 18 |
|
12 | | -COPY . /app/ |
13 | 19 |
|
14 | | -RUN poetry install --no-root --only $(python ./tools/get_plugins_list.py) \ |
15 | | - && poetry cache clear --no-interaction --all . |
| 20 | +# Sentinela image |
| 21 | +FROM python:${PYTHON_VERSION}-alpine AS sentinela |
| 22 | + |
| 23 | +ENV VIRTUAL_ENV=/opt/venv \ |
| 24 | + PATH="/opt/venv/bin:$PATH" |
| 25 | + |
| 26 | +WORKDIR /app |
| 27 | + |
| 28 | +COPY --from=base /app /app |
| 29 | +COPY --from=base /opt /opt |
16 | 30 |
|
17 | 31 |
|
18 | | -FROM sentinela AS sentinela_dev |
| 32 | +# Base dev image |
| 33 | +FROM base AS base_dev |
| 34 | + |
| 35 | +RUN poetry install --only dev |
| 36 | + |
| 37 | + |
| 38 | +# Sentinela dev image |
| 39 | +FROM python:${PYTHON_VERSION}-alpine AS sentinela_dev |
| 40 | + |
| 41 | +ENV VIRTUAL_ENV=/opt/venv \ |
| 42 | + PATH="/opt/venv/bin:$PATH" |
| 43 | + |
| 44 | +WORKDIR /app |
19 | 45 |
|
20 | | -RUN poetry install --no-root \ |
21 | | - && poetry cache clear --no-interaction --all . |
| 46 | +COPY --from=base_dev /app /app |
| 47 | +COPY --from=base_dev /opt /opt |
0 commit comments