diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 3786ef2..102c24d 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -64,6 +64,7 @@ jobs: strategy: matrix: docker_target: + - migrations - http - socketio - dramatiq diff --git a/Dockerfile b/Dockerfile index a7bc405..5745f43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,19 +61,22 @@ FROM base_builder AS http_builder RUN --mount=type=cache,target=~/.cache/uv \ uv sync --no-dev --group http --no-install-project --frozen --no-editable -# Installs requirements to run production http application +# Installs requirements to run production socketio application FROM base_builder AS socketio_builder RUN --mount=type=cache,target=~/.cache/uv \ uv sync --no-dev --group socketio --no-install-project --frozen --no-editable +# Installs requirements to run production migrations application +FROM base_builder AS migrations_builder +RUN --mount=type=cache,target=~/.cache/uv \ + uv sync --no-dev --group migrations --no-install-project --frozen --no-editable + # Create the base app with the common python packages FROM base AS base_app USER nonroot COPY --chown=nonroot:nonroot src/common ./common COPY --chown=nonroot:nonroot src/domains ./domains COPY --chown=nonroot:nonroot src/gateways ./gateways -COPY --chown=nonroot:nonroot src/migrations ./migrations -COPY --chown=nonroot:nonroot src/alembic.ini . # Copy the http python package and requirements from relevant builder FROM base_app AS http @@ -89,6 +92,14 @@ COPY --chown=nonroot:nonroot src/socketio_app ./socketio_app # Run CMD using array syntax, so it uses `exec` and runs as PID1 CMD ["python", "-m", "socketio_app"] +# Copy the socketio python package and requirements from relevant builder +FROM base_app AS migrations +COPY --from=migrations_builder /venv /venv +COPY --chown=nonroot:nonroot src/migrations ./migrations +COPY --chown=nonroot:nonroot src/alembic.ini . +# Run CMD using array syntax, so it uses `exec` and runs as PID1 +CMD ["alembic", "upgrade", "heads"] + # Copy the dramatiq python package and requirements from relevant builder FROM base_app AS dramatiq COPY --from=dramatiq_builder /venv /venv diff --git a/pyproject.toml b/pyproject.toml index 9d59999..70272ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,6 @@ description = "" readme = "README.md" dependencies = [ "aiosqlite>=0.18.0", - "alembic<2.0.0,>=1.11.1", "asgiref<4.0.0,>=3.7.2", "cloudevents-pydantic<1.0.0,>=0.0.3", "dependency-injector[pydantic]<5.0.0,>=4.41.0", @@ -50,6 +49,10 @@ socketio = [ "starlette>=0.45.3", "uvicorn[standard]<1.0.0,>=0.34.0", ] +migrations = [ + "alembic<2.0.0,>=1.11.1", + "factory-boy<4.0.0,>=3.3.3", +] dev = [ "asynctest", "coverage", diff --git a/uv.lock b/uv.lock index 53453fa..aee229e 100644 --- a/uv.lock +++ b/uv.lock @@ -1,4 +1,5 @@ version = 1 +revision = 1 requires-python = ">=3.10, <3.14" [[package]] @@ -118,7 +119,6 @@ version = "0.1.0" source = { editable = "." } dependencies = [ { name = "aiosqlite" }, - { name = "alembic" }, { name = "asgiref" }, { name = "cloudevents-pydantic" }, { name = "dependency-injector", extra = ["pydantic"] }, @@ -168,6 +168,10 @@ http = [ { name = "strawberry-graphql", extra = ["debug-server"] }, { name = "uvicorn", extra = ["standard"] }, ] +migrations = [ + { name = "alembic" }, + { name = "factory-boy" }, +] socketio = [ { name = "python-socketio" }, { name = "starlette" }, @@ -177,7 +181,6 @@ socketio = [ [package.metadata] requires-dist = [ { name = "aiosqlite", specifier = ">=0.18.0" }, - { name = "alembic", specifier = ">=1.11.1,<2.0.0" }, { name = "asgiref", specifier = ">=3.7.2,<4.0.0" }, { name = "cloudevents-pydantic", specifier = ">=0.0.3,<1.0.0" }, { name = "dependency-injector", extras = ["pydantic"], specifier = ">=4.41.0,<5.0.0" }, @@ -227,6 +230,10 @@ http = [ { name = "strawberry-graphql", extras = ["debug-server"], specifier = ">=0.204.0" }, { name = "uvicorn", extras = ["standard"], specifier = ">=0.34.0,<1.0.0" }, ] +migrations = [ + { name = "alembic", specifier = ">=1.11.1,<2.0.0" }, + { name = "factory-boy", specifier = ">=3.3.3,<4.0.0" }, +] socketio = [ { name = "python-socketio", specifier = ">=5.12.1" }, { name = "starlette", specifier = ">=0.45.3" },