diff --git a/services/docker-compose.yml b/services/docker-compose.yml --- a/services/docker-compose.yml +++ b/services/docker-compose.yml @@ -1,4 +1,7 @@ version: "3.9" +networks: + services-net: + name: services-net services: tunnelbroker-server: build: @@ -52,3 +55,18 @@ - "${COMM_SERVICES_PORT_BLOB}:50051" volumes: - $HOME/.aws/credentials:/root/.aws/credentials:ro + # localstack + localstack: + image: localstack/localstack + container_name: localstack + hostname: localstack + ports: + - "4566:4566" + environment: + - SERVICES=s3,dynamodb + - DEFAULT_REGION=eu-east-2 + - DATA_DIR=/tmp/localstack/data + - DOCKER_HOST=unix:///var/run/docker.sock + - HOSTNAME_EXTERNAL=localstack + networks: + - services-net diff --git a/services/package.json b/services/package.json --- a/services/package.json +++ b/services/package.json @@ -22,6 +22,8 @@ "test-all-services": "./scripts/test_all_services.sh", "test-all-services-dev-mode": "export COMM_SERVICES_DEV_MODE=1 && ./scripts/test_all_services.sh", "run-all-services-dev-mode": "export COMM_SERVICES_DEV_MODE=1 && ./scripts/run_all_services.sh", - "backup-aws": "./scripts/backup_aws.sh" + "backup-aws": "./scripts/backup_aws.sh", + "run-local-cloud": "./scripts/run_local_cloud.sh", + "setup-local-cloud": "./scripts/setup_localstack.sh" } } diff --git a/services/scripts/run_local_cloud.sh b/services/scripts/run_local_cloud.sh new file mode 100755 --- /dev/null +++ b/services/scripts/run_local_cloud.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +docker-compose up -d --force-recreate localstack \ No newline at end of file diff --git a/services/scripts/setup_localstack.sh b/services/scripts/setup_localstack.sh new file mode 100755 --- /dev/null +++ b/services/scripts/setup_localstack.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +DYNAMO_DB_TABLES_FOLDER="./aws_backup/dynamo_db_tables" + +# S3 +echo "setting up S3..." +BUCKETS=`cat ./aws_backup/s3.dump || echo "error: there was a problem with the aws backup"` +for BUCKET in $BUCKETS; do + echo " creating bucket $BUCKET" + aws --endpoint-url=http://localhost:4566 s3 mb s3://$BUCKET > /dev/null +done + +# dynamoDB +echo "setting up database..." +DYNAMO_DB_TABLES=`ls $DYNAMO_DB_TABLES_FOLDER` +for TABLE in $DYNAMO_DB_TABLES; do + echo " creating table $TABLE" + aws --endpoint-url=http://localhost:4566 dynamodb create-table --cli-input-json file://$DYNAMO_DB_TABLES_FOLDER/$TABLE > /dev/null +done + + +echo "setting up - DONE"