forked from robusta-dev/robusta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
73 lines (55 loc) · 2.19 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
70
71
72
73
# Build stage
FROM python:3.11-slim as builder
ENV PATH="/root/.local/bin/:$PATH"
RUN apt-get update \
&& dpkg --add-architecture arm64 \
&& apt-get install -y --no-install-recommends curl gcc \
&& pip3 install --no-cache-dir --upgrade pip \
&& rm -rf /var/lib/apt/lists/*
ENV ENV_TYPE=DEV
RUN mkdir /app
WORKDIR /app
# Create and activate virtual environment
RUN python -m venv /app/venv --upgrade-deps && \
. /app/venv/bin/activate
ENV VIRTUAL_ENV=/app/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN poetry config virtualenvs.create false
# Install gcc to compile ruamel.yaml.clib, wheel is missing.
RUN pip3 install --no-cache-dir ruamel.yaml.clib==0.2.8
# Install project dependencies
COPY pyproject.toml poetry.lock /app/
RUN poetry install --no-root --without dev --extras "all"
# Copy project source code
COPY src/ /app/src
RUN poetry install --without dev --extras "all"
# Install playbooks
COPY playbooks/ /etc/robusta/playbooks/defaults
RUN pip install --no-cache-dir /etc/robusta/playbooks/defaults
# Final stage
FROM python:3.11-slim
ENV ENV_TYPE=DEV
ENV PYTHONUNBUFFERED=1
ENV VIRTUAL_ENV=/app/venv
ENV PATH="/venv/bin:$PATH"
ENV PYTHONPATH=$PYTHONPATH:.:/app/src
WORKDIR /app
# Install necessary packages for the runtime environment
RUN apt-get update \
&& dpkg --add-architecture arm64 \
&& pip3 install --no-cache-dir --upgrade pip \
&& apt-get install -y --no-install-recommends git ssh curl libcairo2 \
&& rm -rf /var/lib/apt/lists/*
# Patching CVE-2024-32002
RUN git config --global core.symlinks false
# Remove setuptools-65.5.1 installed from python:3.11-slim base image as fix for CVE-2024-6345 until image will be updated
RUN rm -rf /usr/local/lib/python3.11/site-packages/setuptools-65.5.1.dist-info
COPY --from=builder /app/venv /venv
COPY --from=builder /etc/robusta/playbooks/defaults /etc/robusta/playbooks/defaults
# Copy virtual environment and application files from the build stage
COPY --from=builder /app /app
# Run the application
# -u disables stdout buffering https://stackoverflow.com/questions/107705/disable-output-buffering
CMD [ "python3", "-u", "-m", "robusta.runner.main"]