Skip to content

Commit

Permalink
Separate dev dependencies and add pre-commit support (#304)
Browse files Browse the repository at this point in the history
* Adding support for dev dependencies

* Adding new dependencies with pre-commit

* Adding debug

* Dockerfile test

* Fixing run installation and other bugs

* Adding common uv for pre-commit

* Adding target to the action

* Changing lock file back

---------

Signed-off-by: Mario Cariñana <[email protected]>
  • Loading branch information
macaab26 authored Oct 28, 2024
1 parent 4320cc8 commit 3a4b614
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .devcontainer/docker-compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: lumigator
services:

backend:
command: ["uv", "run", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
build:
context: .
dockerfile: "Dockerfile"
target: "dev_image"
volumes:
- ./:/mzai
1 change: 1 addition & 0 deletions .github/workflows/build_images_uv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
push: true
target: "main_image"
tags: |
mzdotai/lumigator:backend_dev_${{ env.REPOVERSION }}
${{ github.ref == 'refs/heads/main' && 'mzdotai/lumigator:latest' || '' }}
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
FROM python:3.11-slim-bookworm
FROM python:3.11-slim-bookworm AS base
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

# Copy the project into the image
ADD . /mzai


WORKDIR /mzai/lumigator/python/mzai/backend

# Sync the project into a new environment, using the frozen lockfile
FROM base AS main_image

# Sync the project into a new environment, using the frozen lockfile and no dev dependencies
RUN uv sync --no-dev --frozen

CMD ["uv", "run", "--no-dev", "uvicorn", "--host", "0.0.0.0", "--port", "8000", "backend.main:app"]

FROM base AS dev_image

# Sync the project into a new environment, using the frozen lockfile and no dev dependencies
RUN uv sync --frozen

CMD ["uv", "run", "uvicorn", "--host", "0.0.0.0", "--port", "8000", "backend.main:app"]
CMD ["uv", "run", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ DEV_DOCKER_COMPOSE_FILE:= .devcontainer/docker-compose.override.yaml
# Launches Lumigator in 'development' mode (all services running locally, code mounted in)
local-up:
RAY_ARCH_SUFFIX=$(RAY_ARCH_SUFFIX) docker compose --profile local -f $(LOCAL_DOCKERCOMPOSE_FILE) -f ${DEV_DOCKER_COMPOSE_FILE} up -d --build
uv run pre-commit install

local-down:
docker compose --profile local -f $(LOCAL_DOCKERCOMPOSE_FILE) down
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ services:
build:
context: .
dockerfile: "Dockerfile"
target: "main_image"
platform: linux/amd64
depends_on:
localstack:
Expand Down Expand Up @@ -125,4 +126,4 @@ services:

volumes:

localstack-data:
localstack-data:
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[project]
name = "common"
version = "0.1.0"
description = "Common deps to develop"
requires-python = ">=3.11"
dependencies = [
"pre-commit>=4.0.1",
]
132 changes: 132 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a4b614

Please sign in to comment.