Skip to content

Commit ad8fcfa

Browse files
committed
small adjustments
1 parent 954746b commit ad8fcfa

File tree

7 files changed

+67
-19
lines changed

7 files changed

+67
-19
lines changed

.dockerignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
**/__pycache__
2-
**/.mypy_cache
3-
**/.pytest_cache
41
_monitors
2+
_monitors_load
3+
.coverage
4+
.git
5+
.mypy_cache
6+
.pytest_cache
7+
.ruff_cache
8+
.vscode
9+
**/__pycache__
10+
**/*.pyc
11+
**/*.pyd
12+
**/*.pyo
13+
docs
14+
tmp

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
_monitors
22
_monitors_load
33
.coverage
4+
.mypy_cache
5+
.pytest_cache
46
.ruff_cache
57
.vscode
68
**/__pycache__

Dockerfile

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
1-
FROM python:3.12-alpine AS sentinela
1+
ARG PYTHON_VERSION=3.12
22

3+
# Base image
4+
FROM python:${PYTHON_VERSION}-alpine AS base
5+
6+
ARG SENTINELA_PLUGINS
37
ENV VIRTUAL_ENV=/opt/venv \
48
PATH="/opt/venv/bin:$PATH"
59

610
WORKDIR /app
11+
COPY . /app/
712

813
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
1118

12-
COPY . /app/
1319

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
1630

1731

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
1945

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

docker-compose-dev.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ services:
2222
context: .
2323
dockerfile: Dockerfile
2424
target: sentinela_dev
25+
args:
26+
SENTINELA_PLUGINS: slack
2527
image: sentinela-dev:latest
2628
ports:
2729
- 8000:8000
@@ -36,6 +38,10 @@ services:
3638
- .env.secrets
3739
volumes:
3840
- .:/app:Z
41+
# Paths that won't be synced with the container
42+
- /app/src/_monitors
43+
- /app/src/_monitors_load
44+
- /app/src/tmp
3945
depends_on:
4046
- postgres
4147
- motoserver

docker-compose-local.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ services:
1111
context: .
1212
dockerfile: Dockerfile
1313
target: sentinela
14+
args:
15+
SENTINELA_PLUGINS: slack
1416
image: sentinela-local:latest
1517
ports:
1618
- 8000:8000

pyproject.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
[build-system]
2-
requires = ["poetry-core"]
3-
build-backend = "poetry.core.masonry.api"
4-
5-
[tool.poetry]
1+
[project]
62
name = "Sentinela"
73
version = "0.3.2"
84
description = "Sentinela Monitoring Platform"
9-
authors = ["Gabriel Salla <gabriel.c.salla@gmail.com>"]
10-
license = "MIT"
5+
authors = [
6+
{ name = "Gabriel Salla", email = "gabriel.c.salla@gmail.com" }
7+
]
8+
license = { file = "LICENSE.txt" }
119
readme = "README.md"
1210

11+
[tool.poetry]
12+
package-mode = false
13+
1314
[tool.poetry.dependencies]
1415
python = "^3.12"
1516
aioboto3 = "^13.2.0"

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ async def clear_database(init_databases):
106106
@pytest.fixture(scope="session", autouse=True)
107107
def _temp_dir(monkeypatch_session):
108108
"""Create a temporary directory for all the tests that will be removed at the end"""
109+
shutil.rmtree("src/tmp", ignore_errors=True)
109110
os.makedirs("src/tmp", exist_ok=True)
110111
monkeypatch_session.setattr(monitors_loader, "MONITORS_LOAD_PATH", "tmp")
111112
monkeypatch_session.setattr(module_loader.loader, "MODULES_PATH", "tmp")

0 commit comments

Comments
 (0)