Skip to content

Commit 9885ff6

Browse files
authored
Separate migrations app (#260)
1 parent d81cff9 commit 9885ff6

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

.github/workflows/ci-pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
strategy:
6565
matrix:
6666
docker_target:
67+
- migrations
6768
- http
6869
- socketio
6970
- dramatiq

Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,22 @@ FROM base_builder AS http_builder
6161
RUN --mount=type=cache,target=~/.cache/uv \
6262
uv sync --no-dev --group http --no-install-project --frozen --no-editable
6363

64-
# Installs requirements to run production http application
64+
# Installs requirements to run production socketio application
6565
FROM base_builder AS socketio_builder
6666
RUN --mount=type=cache,target=~/.cache/uv \
6767
uv sync --no-dev --group socketio --no-install-project --frozen --no-editable
6868

69+
# Installs requirements to run production migrations application
70+
FROM base_builder AS migrations_builder
71+
RUN --mount=type=cache,target=~/.cache/uv \
72+
uv sync --no-dev --group migrations --no-install-project --frozen --no-editable
73+
6974
# Create the base app with the common python packages
7075
FROM base AS base_app
7176
USER nonroot
7277
COPY --chown=nonroot:nonroot src/common ./common
7378
COPY --chown=nonroot:nonroot src/domains ./domains
7479
COPY --chown=nonroot:nonroot src/gateways ./gateways
75-
COPY --chown=nonroot:nonroot src/migrations ./migrations
76-
COPY --chown=nonroot:nonroot src/alembic.ini .
7780

7881
# Copy the http python package and requirements from relevant builder
7982
FROM base_app AS http
@@ -89,6 +92,14 @@ COPY --chown=nonroot:nonroot src/socketio_app ./socketio_app
8992
# Run CMD using array syntax, so it uses `exec` and runs as PID1
9093
CMD ["python", "-m", "socketio_app"]
9194

95+
# Copy the socketio python package and requirements from relevant builder
96+
FROM base_app AS migrations
97+
COPY --from=migrations_builder /venv /venv
98+
COPY --chown=nonroot:nonroot src/migrations ./migrations
99+
COPY --chown=nonroot:nonroot src/alembic.ini .
100+
# Run CMD using array syntax, so it uses `exec` and runs as PID1
101+
CMD ["alembic", "upgrade", "heads"]
102+
92103
# Copy the dramatiq python package and requirements from relevant builder
93104
FROM base_app AS dramatiq
94105
COPY --from=dramatiq_builder /venv /venv

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ description = ""
99
readme = "README.md"
1010
dependencies = [
1111
"aiosqlite>=0.18.0",
12-
"alembic<2.0.0,>=1.11.1",
1312
"asgiref<4.0.0,>=3.7.2",
1413
"cloudevents-pydantic<1.0.0,>=0.0.3",
1514
"dependency-injector[pydantic]<5.0.0,>=4.41.0",
@@ -50,6 +49,10 @@ socketio = [
5049
"starlette>=0.45.3",
5150
"uvicorn[standard]<1.0.0,>=0.34.0",
5251
]
52+
migrations = [
53+
"alembic<2.0.0,>=1.11.1",
54+
"factory-boy<4.0.0,>=3.3.3",
55+
]
5356
dev = [
5457
"asynctest",
5558
"coverage",

uv.lock

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)