From 759e745098d2e7cb582c0097c18c042e32533012 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Fri, 12 Jul 2024 11:08:00 +0200 Subject: [PATCH] feat(docker): Update entrypoint (#4262) --- .github/actions/api-deploy-ecs/action.yml | 2 +- api/scripts/run-docker.sh | 35 ++----------------- .../importing-and-exporting/organisations.md | 6 ++-- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/.github/actions/api-deploy-ecs/action.yml b/.github/actions/api-deploy-ecs/action.yml index e6a367a830a3..a9b2dc984bfb 100644 --- a/.github/actions/api-deploy-ecs/action.yml +++ b/.github/actions/api-deploy-ecs/action.yml @@ -130,7 +130,7 @@ runs: }, "InputTransformer": { "InputPathsMap":{"project_id":"$.detail.project_id"}, - "InputTemplate": "{ \"containerOverrides\": [ { \"name\": \"flagsmith-api-migration\", \"command\": [\"migrate-identities\", ], \" environment \":[{\"PROJECT_METADATA_TABLE_NAME_DYNAMO\":\"flagsmith_project_metadata\"}]}]}" + "InputTemplate": "{ \"containerOverrides\": [ { \"name\": \"flagsmith-api-migration\", \"command\": [\"migrate_to_edge\", ], \" environment \":[{\"PROJECT_METADATA_TABLE_NAME_DYNAMO\":\"flagsmith_project_metadata\"}]}]}" } } ]' diff --git a/api/scripts/run-docker.sh b/api/scripts/run-docker.sh index 7fa0ff47dda9..d563b8946dc9 100755 --- a/api/scripts/run-docker.sh +++ b/api/scripts/run-docker.sh @@ -1,10 +1,6 @@ #!/bin/bash set -e -# The script can take 2 optional arguments: -# 1. The django target to run -# 2. For migrate, serve and migrate-and-serve, the number of seconds to sleep before running - function migrate () { python manage.py waitfordb && python manage.py migrate && python manage.py createcachetable } @@ -40,9 +36,6 @@ function run_task_processor() { --numthreads ${TASK_PROCESSOR_NUM_THREADS:-5} \ --queuepopsize ${TASK_PROCESSOR_QUEUE_POP_SIZE:-10} } -function migrate_identities(){ - python manage.py migrate_to_edge "$1" -} function migrate_analytics_db(){ # if `$ANALYTICS_DATABASE_URL` or DJANGO_DB_NAME_ANALYTICS is set # run the migration command @@ -51,47 +44,25 @@ function migrate_analytics_db(){ fi python manage.py migrate --database analytics } -function import_organisation_from_s3(){ - python manage.py importorganisationfroms3 "$1" "$2" -} -function dump_organisation_to_s3(){ - python manage.py dumporganisationtos3 "$1" "$2" "$3" -} -function dump_organisation_to_local_fs(){ - python manage.py dumporganisationtolocalfs "$1" "$2" -} function bootstrap(){ python manage.py bootstrap } -# Note: `go_to_sleep` is deprecated and will be removed in a future release. -function go_to_sleep(){ - echo "Sleeping for ${1} seconds before startup" - sleep ${1} +function default(){ + python manage.py "$@" } if [ "$1" == "migrate" ]; then - if [ $# -eq 2 ]; then go_to_sleep "$2"; fi migrate migrate_analytics_db elif [ "$1" == "serve" ]; then - if [ $# -eq 2 ]; then go_to_sleep "$2"; fi serve elif [ "$1" == "run-task-processor" ]; then run_task_processor elif [ "$1" == "migrate-and-serve" ]; then - if [ $# -eq 2 ]; then go_to_sleep "$2"; fi migrate migrate_analytics_db bootstrap serve -elif [ "$1" == "migrate-identities" ]; then - migrate_identities "$2" -elif [ "$1" == "import-organisation-from-s3" ]; then - import_organisation_from_s3 "$2" "$3" -elif [ "$1" == "dump-organisation-to-s3" ]; then - dump_organisation_to_s3 "$2" "$3" "$4" -elif [ "$1" == "dump-organisation-to-local-fs" ]; then - dump_organisation_to_local_fs "$2" "$3" else - echo "ERROR: unrecognised command '$1'" + default "$@" fi diff --git a/docs/docs/system-administration/importing-and-exporting/organisations.md b/docs/docs/system-administration/importing-and-exporting/organisations.md index 461002711813..0c184ea25cdd 100644 --- a/docs/docs/system-administration/importing-and-exporting/organisations.md +++ b/docs/docs/system-administration/importing-and-exporting/organisations.md @@ -116,7 +116,7 @@ services: environment: DATABASE_URL: postgresql://postgres:password@postgres:5432/flagsmith command: - - 'dump-organisation-to-local-fs' + - 'dumporganisationtolocalfs' - '1' - '/tmp/flagsmith-exporter/org-1.json' depends_on: @@ -164,13 +164,13 @@ This is coming soon - see https://github.com/Flagsmith/flagsmith/issues/2512 for ### Option 2 - S3 bucket ```bash -python manage.py import-organisation-from-s3 +python manage.py importorganisationfroms3 ``` e.g. ```bash -python manage.py import-organisation-from-s3 my-export-bucket exports/organisation-1.json +python manage.py importorganisationfroms3 my-export-bucket exports/organisation-1.json ``` #### Using localstack to achieve local/test imports with s3 can be done using