Skip to content

Commit

Permalink
remove venv in poetry and strealmine docker image
Browse files Browse the repository at this point in the history
(review comments)
  • Loading branch information
mki-c2c committed Jan 21, 2025
1 parent ac16f6f commit c70e9e0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
15 changes: 10 additions & 5 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
FROM python:3.12-slim-bullseye AS poetry

RUN pip install poetry
RUN --mount=type=cache,target=/root/.cache \
pip install poetry
RUN poetry config virtualenvs.create false

RUN mkdir /app
WORKDIR /app

COPY pyproject.toml /app

FROM poetry as server
RUN poetry install --no-root
RUN --mount=type=cache,target=/root/.cache \
poetry install --no-root

COPY . /app

RUN poetry install
RUN --mount=type=cache,target=/root/.cache \
poetry install

CMD ["poetry", "run", "fastapi", "dev", "--host", "0.0.0.0", "main.py"]
CMD ["serve_prod"]

FROM server as check

RUN poetry install --no-root --with check
RUN --mount=type=cache,target=/root/.cache \
poetry install --no-root --with check

CMD ["/app/maelstro/scripts/code_check.sh"]
12 changes: 12 additions & 0 deletions backend/maelstro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ def root_page():
return {"Hello": "World"}


@app.get("/auth")
def auth_page(
sec_roles: Annotated[str, Header(include_in_schema=False)] = "",
):
"""
Check if the user is authorized for the maestro sync platform via the MAELSTRO role
"""
return {"is_authorized": "ROLE_MAELSTRO" in sec_roles.split(";")}


@app.get("/user")
def user_page(
sec_username: Annotated[str | None, Header(include_in_schema=False)] = None,
Expand All @@ -44,6 +54,8 @@ def user_page(
}


# pylint: disable=fixme
# TODO: deactivate for prod
@app.head("/debug")
@app.get("/debug")
@app.put("/debug")
Expand Down
6 changes: 3 additions & 3 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pytest = "^8.3.4"

[tool.poetry.scripts]
health_check = "maelstro.scripts.health_check:check"
dev = "maelstro:dev"
docker_dev = "maelstro:docker_dev"
prod = "maelstro:prod"
serve_dev = "maelstro:dev"
serve_docker_dev = "maelstro:docker_dev"
serve_prod = "maelstro:prod"

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
Expand Down
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ services:
timeout: 10s

command:
- poetry
- run
- docker_dev
- serve_docker_dev

check:
profiles:
Expand Down

0 comments on commit c70e9e0

Please sign in to comment.