Skip to content

Separate migrations app #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
strategy:
matrix:
docker_target:
- migrations
- http
- socketio
- dramatiq
Expand Down
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 9 additions & 2 deletions uv.lock

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

Loading