-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsonar.Dockerfile
More file actions
57 lines (41 loc) · 1.47 KB
/
sonar.Dockerfile
File metadata and controls
57 lines (41 loc) · 1.47 KB
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
FROM python:3.10.12
ARG MY_ENV
ENV MY_ENV=${MY_ENV} \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.5.0
ENV user=alab
ENV SOAR_FOLDER=soar
# Update and install dependencies
RUN apt update --fix-missing && \
apt-get install -y git graphviz && \
apt-get autoremove -y && apt-get autoclean -y && \
rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -ms /bin/bash ${user} && echo '${user} ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers
# Add location where pip is installed to the PATH variable
ENV PATH="/home/${user}/.local/bin:${PATH}"
# Install poetry as user
USER ${user}
RUN pip3 install poetry=="${POETRY_VERSION}"
WORKDIR /home/${user}/${SOAR_FOLDER}
COPY --chown=${user}:${user} pyproject.toml poetry.lock /home/${user}/${SOAR_FOLDER}/
# Install dependencies (--no-root avoids errors when source not yet copied)
# RUN poetry install --no-root
# Copy project files
COPY --chown=${user}:${user} . /home/${user}/${SOAR_FOLDER}
# Install only SONAR dependencies
RUN poetry install --with sonar
RUN poetry install --only-root
# Install SONAR as editable package (creates sonar CLI entrypoint)
# RUN poetry install
# Set PYTHONPATH
ENV PYTHONPATH=/home/${user}/${SOAR_FOLDER}:${PYTHONPATH}
# Set the entrypoint to SONAR CLI
ENTRYPOINT ["poetry", "run", "python", "sonar/cli.py"]
# Default command (can be overridden)
CMD ["--help"]