fix migration script

This commit is contained in:
2026-08-31 15:39:35 +03:00
parent e0ebf45ccb
commit 230dd5201b
3 changed files with 9 additions and 56 deletions
-28
View File
@@ -37,8 +37,6 @@ services:
depends_on: depends_on:
psql: psql:
condition: service_healthy condition: service_healthy
migration:
condition: service_completed_successfully
ports: ports:
- "80:8000" - "80:8000"
entrypoint: ["./entrypoint.sh", "--dev"] entrypoint: ["./entrypoint.sh", "--dev"]
@@ -74,8 +72,6 @@ services:
depends_on: depends_on:
psql: psql:
condition: service_healthy condition: service_healthy
migration:
condition: service_completed_successfully
ports: ports:
- "80:8000" - "80:8000"
@@ -104,30 +100,6 @@ services:
ports: ports:
- "5432:5432" - "5432:5432"
migration:
profiles: ["prod", "dev"]
image: "${DOCKER_REGISTRY:-local}/migration-tool:${IMAGE_TAG:-local}"
build:
dockerfile: ./docker/dockerfile
context: ../
target: migration-tool
environment:
- DB_HOST=psql
volumes:
- type: bind
source: ../configs
target: /home/excel-project/configs
- type: bind
source: ../src/migrations
target: /home/excel-project/src/migrations
depends_on:
- psql
networks:
- backend
networks: networks:
backend: backend:
name: "${BACKEND_NETWORK:-backend_network}" name: "${BACKEND_NETWORK:-backend_network}"
+2 -26
View File
@@ -6,7 +6,7 @@ LABEL org.opencontainers.image.source="https://git.homyk.space/MH.Dmitrii/The_Di
WORKDIR /home/excel-project WORKDIR /home/excel-project
COPY pyproject.toml poetry.lock docker/entrypoint.sh ./ COPY pyproject.toml poetry.lock docker/entrypoint.sh alembic.ini ./
RUN chmod +x ./entrypoint.sh RUN chmod +x ./entrypoint.sh
@@ -23,7 +23,7 @@ LABEL org.opencontainers.image.source="https://git.homyk.space/MH.Dmitrii/The_Di
WORKDIR /home/excel-project WORKDIR /home/excel-project
COPY pyproject.toml poetry.lock main.py docker/entrypoint.sh ./ COPY pyproject.toml poetry.lock main.py docker/entrypoint.sh alembic.ini ./
COPY src/ ./src/ COPY src/ ./src/
RUN chmod +x ./entrypoint.sh RUN chmod +x ./entrypoint.sh
@@ -39,27 +39,3 @@ RUN groupadd --gid 1000 appuser \
USER appuser USER appuser
ENTRYPOINT ["./entrypoint.sh", "--prod"] ENTRYPOINT ["./entrypoint.sh", "--prod"]
FROM python:3.14-slim AS migration-tool
LABEL org.opencontainers.image.title="The-DisExcel-project"
LABEL org.opencontainers.image.source="https://git.homyk.space/MH.Dmitrii/The_DisExcel_project"
WORKDIR /home/excel-project
COPY pyproject.toml poetry.lock alembic.ini ./
COPY src/models/database_models ./src/models/database_models
COPY src/models/configs_read ./src/models/configs_read
RUN pip install --no-cache-dir --break-system-packages poetry \
&& poetry config virtualenvs.create false \
&& poetry install --no-root --no-interaction --only main
RUN groupadd --gid 1000 appuser \
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser \
&& chown -R appuser:appuser /home/excel-project
USER appuser
CMD ["alembic", "upgrade", "head"]
+5
View File
@@ -21,6 +21,11 @@ if [ -z "$MODE" ]; then
exit 1 exit 1
fi fi
if ! alembic upgrade head; then
echo "Migration failed"
exit 1
fi
if [ "$MODE" = "dev" ]; then if [ "$MODE" = "dev" ]; then
WORKERS="${WORKERS:-1}" WORKERS="${WORKERS:-1}"
exec gunicorn \ exec gunicorn \