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
24 changes: 22 additions & 2 deletions .github/workflows/deploy-to-ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,33 @@ jobs:
container-name: dataspace
image: ${{ steps.build-image.outputs.image }}

- name: Deploy main application ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
- name: Get running service's network configuration
id: network-config
run: |
NETWORK_CONFIG=$(aws ecs describe-services \
--cluster "${{ env.ECS_CLUSTER }}" \
--services "${{ secrets.ECS_SERVICE }}" \
--query 'services[0].networkConfiguration.awsvpcConfiguration' \
--output json)
{
echo "subnets=$(echo "$NETWORK_CONFIG" | jq -r '.subnets | join(",")')"
echo "security_groups=$(echo "$NETWORK_CONFIG" | jq -r '.securityGroups | join(",")')"
echo "assign_public_ip=$(echo "$NETWORK_CONFIG" | jq -r '.assignPublicIp')"
} >> "$GITHUB_OUTPUT"

- name: Run migrations, then deploy the ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.task-def-app.outputs.task-definition }}
service: ${{ secrets.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
run-task: true
run-task-container-overrides: '[{"name":"dataspace","command":["python","manage.py","migrate","--noinput"]}]'
run-task-subnets: ${{ steps.network-config.outputs.subnets }}
run-task-security-groups: ${{ steps.network-config.outputs.security_groups }}
run-task-assign-public-IP: ${{ steps.network-config.outputs.assign_public_ip }}
wait-for-task-stopped: true

deploy-otel:
name: Deploy OpenTelemetry Collector
Expand Down
13 changes: 6 additions & 7 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ while True:
time.sleep(2)
END

# Ensure migrations directory exists with proper permissions
echo "Ensuring migrations directory exists..."
mkdir -p /code/api/migrations
chmod -R 777 /code/api/migrations
touch /code/api/migrations/__init__.py

# Run migrations
# Run migrations. In the ECS pipeline this also runs earlier as an explicit
# one-off task before this service is deployed (see deploy-to-ecs.yml) so a
# broken migration fails the deploy loudly and visibly instead of surfacing
# only once containers are already shipping; this call is then a no-op
# (migrate is idempotent). Kept here unconditionally too, since this same
# entrypoint/image is what `docker compose up` uses for local dev.
echo "Running migrations..."
python manage.py migrate --noinput

Expand Down