From 4532a4807cc5038ae7708541bf78d9659f244664 Mon Sep 17 00:00:00 2001 From: mandanakhademi Date: Mon, 4 Mar 2024 17:08:36 +0000 Subject: [PATCH] Update docker compose to fix the issue with localstack --- .github/workflows/deploy-aws-staging.yml | 9 +++++++++ .gitignore | 3 +++ app/services/storage_service.rb | 5 +++-- bin/init-s3-localstack.py | 2 +- docker-compose.yml | 3 ++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-aws-staging.yml b/.github/workflows/deploy-aws-staging.yml index 0c5da821..ebf5b3c3 100644 --- a/.github/workflows/deploy-aws-staging.yml +++ b/.github/workflows/deploy-aws-staging.yml @@ -99,6 +99,15 @@ jobs: - name: Compile Assets run: | bundle exec rake assets:precompile + - name: Run localstack + run: | + docker run -d\ + --rm \ + -p 4566:4566 \ + -v "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack" \ + -v "/var/run/docker.sock:/var/run/docker.sock" \ + -v "./bin/init-s3-localstack.py:/etc/localstack/init/ready.d/init-s3.py" \ + localstack/localstack:s3-latest - name: Run tests run: | bundle exec rake diff --git a/.gitignore b/.gitignore index 204fd3ee..999f69a0 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,6 @@ yarn-debug.log* # Ignore Vscode Settings data/startup_info.json + +# Key File +/volume/cache/* diff --git a/app/services/storage_service.rb b/app/services/storage_service.rb index 99296bb1..52758751 100644 --- a/app/services/storage_service.rb +++ b/app/services/storage_service.rb @@ -49,9 +49,10 @@ def create_configuration end def create_client - if Rails.env.test? + if Rails.env.development? || Rails.env.test? Aws::S3::Client.new( - endpoint: "http://localhost:4566", + endpoint: "http://127.0.0.1:4566", + region: @configuration.region, credentials: Aws::Credentials.new( @configuration.access_key_id, @configuration.secret_access_key, diff --git a/bin/init-s3-localstack.py b/bin/init-s3-localstack.py index 5720d2a9..cb8dfd77 100644 --- a/bin/init-s3-localstack.py +++ b/bin/init-s3-localstack.py @@ -2,7 +2,7 @@ s3_client = boto3.client( "s3", - endpoint_url=f"http://localhost:4566", + endpoint_url=f"http://127.0.0.1:4566", aws_access_key_id="test", aws_secret_access_key="test" ) diff --git a/docker-compose.yml b/docker-compose.yml index b3fb0299..4d74f407 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,9 +49,10 @@ services: environment: - PERSISTENCE=1 ports: - - "4566:4566" + - "127.0.0.1:4566:4566" volumes: - "./bin/init-s3-localstack.py:/etc/localstack/init/ready.d/init-s3.py" + - "/var/run/docker.sock:/var/run/docker.sock" mock-api: build: http-mock-server