Skip to content
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
17 changes: 17 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ jobs:
--cluster ${{ env.ECS_CLUSTER }} \
--services ${{ env.ECS_SERVICE }}

- name: Run database migrations
run: |
# Get the task ARN
TASK_ARN=$(aws ecs list-tasks \
--cluster ${{ env.ECS_CLUSTER }} \
--service-name ${{ env.ECS_SERVICE }} \
--query 'taskArns[0]' \
--output text)

# Execute the migration script inside the container
aws ecs execute-command \
--cluster ${{ env.ECS_CLUSTER }} \
--task $TASK_ARN \
--container aixiv-backend \
--interactive \
--command "/bin/bash scripts/run_migrations.sh" << /dev/null

- name: Get ALB DNS name
id: alb-dns
run: |
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/api/health || exit 1

# Run the application by executing the migration and startup script
CMD ["/bin/bash", "scripts/run_migrations.sh"]
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
10 changes: 2 additions & 8 deletions scripts/run_migrations.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e

# Run database migrations
echo "Applying database migrations..."
echo "Running database migrations..."
alembic upgrade head
echo "Migrations applied successfully."

# Start the Uvicorn server
echo "Starting Uvicorn server..."
exec uvicorn app.main:app --host 0.0.0.0 --port 8000
echo "Migrations completed successfully."