diff --git a/.github/workflows/sse-deploy-production-ecs.yml b/.github/workflows/sse-deploy-production-ecs.yml new file mode 100644 index 0000000..99b2708 --- /dev/null +++ b/.github/workflows/sse-deploy-production-ecs.yml @@ -0,0 +1,32 @@ +name: Deploy SSE to Production ECS + +on: + push: + tags: + - "*" + paths: + - "src/**" + - ".github/**" + - "infrastructure/aws/production/**" +jobs: + deploy-production-ecs: + runs-on: ubuntu-latest + name: Deploy SSE to Production ECS + environment: production + + steps: + - name: Cloning repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Deploy SSE to Production + uses: ./.github/actions/sse-deploy-ecs + with: + aws_access_key_id: AKIARHES7IUAY422LL5W + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws_ecs_cluster_name: flagsmith-api-cluster-eu-west-2-f0b0108 + aws_ecs_service_name: flagsmith-sse-svc-eu-west-2-2dd73e1 + aws_ecr_repository_arn: 084060095745.dkr.ecr.eu-west-2.amazonaws.com/flagsmith-sse-ecr-27095a4 + aws_task_definitions_directory_path: infrastructure/aws/production + diff --git a/.github/workflows/sse-deploy-staging-ecs.yml b/.github/workflows/sse-deploy-staging-ecs.yml index ce37cc0..1ecf459 100644 --- a/.github/workflows/sse-deploy-staging-ecs.yml +++ b/.github/workflows/sse-deploy-staging-ecs.yml @@ -5,9 +5,9 @@ on: branches: - main paths: - - "api/**" + - "src/**" - ".github/**" - - 'infrastructure/aws/staging/**' + - "infrastructure/aws/staging/**" jobs: deploy-staging-ecs: @@ -24,8 +24,8 @@ jobs: - name: Deploy SSE to Staging uses: ./.github/actions/sse-deploy-ecs with: - aws_access_key_id: AKIAUM26IRCPH7BHBLVE - aws_secret_access_key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} + aws_access_key_id: AKIAUM26IRCPKP5BWQSJ + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_ecs_cluster_name: flagsmith-api-cluster-eu-west-2-f241261 aws_ecs_service_name: flagsmith-sse-svc-eu-west-2-43f7af2 aws_ecr_repository_arn: 302456015006.dkr.ecr.eu-west-2.amazonaws.com/flagsmith-sse-ecr-fa16ac8 diff --git a/infrastructure/aws/production/ecs-task-definition-sse.json b/infrastructure/aws/production/ecs-task-definition-sse.json new file mode 100644 index 0000000..4d5cc05 --- /dev/null +++ b/infrastructure/aws/production/ecs-task-definition-sse.json @@ -0,0 +1,44 @@ +{ + "family": "flagsmith-sse", + "networkMode": "awsvpc", + "executionRoleArn": "arn:aws:iam::084060095745:role/task-sse-role-bb6bdb2", + "taskRoleArn": "arn:aws:iam::084060095745:role/task-sse-role-bb6bdb2", + "containerDefinitions": [ + { + "name": "flagsmith-sse", + "command": [ + "uvicorn", + "src.main:app", + "--host", + "0.0.0.0", + "--port", + "8000", + "--no-access-log" + ], + "cpu": 0, + "portMappings": [ + { + "containerPort": 8000, + "hostPort": 8000, + "protocol": "tcp" + } + ], + "essential": true, + "environment": [], + "secrets": [], + "logConfiguration": { + "logDriver": "awslogs", + "options": { + "awslogs-group": "flagsmith-sse-eu-west-2-0c3eaaf", + "awslogs-region": "eu-west-2", + "awslogs-stream-prefix": "awslogs-flagsmith-sse" + } + } + } + ], + "requiresCompatibilities": [ + "FARGATE" + ], + "cpu": "1024", + "memory": "2048" +} diff --git a/src/settings.py b/src/settings.py index e623667..49362d8 100644 --- a/src/settings.py +++ b/src/settings.py @@ -16,8 +16,8 @@ def json_config_settings_source(settings: BaseSettings) -> Dict[str, Any]: A simple settings source that loads variables from a JSON file at the project's root. """ - encoding = settings.__config__.env_file_encoding - env_file = settings.__config__.env_file + encoding = "utf-8" + env_file = "config.json" return json.loads(Path(env_file).read_text(encoding)) @@ -38,9 +38,6 @@ class Settings(BaseSettings): allow_origins: List[str] = ["*"] class Config: - env_file = "config.json" - env_file_encoding = "utf-8" - @classmethod def customise_sources( cls,