diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..75fca1e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,52 @@ +{ + "name": "Polyglot Persistence", + "image": "mcr.microsoft.com/devcontainers/dotnet:9.0", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + "containerEnv": { + "DOTNET_NOLOGO": "true" + }, + "onCreateCommand": "chmod +x /workspaces/developer-bootcamp/polyglot-persistence/onCreateCommand.sh && /workspaces/developer-bootcamp/polyglot-persistence/onCreateCommand.sh", + "postCreateCommand": "chmod +x /workspaces/developer-bootcamp/polyglot-persistence/postCreateCommand.sh && /workspaces/developer-bootcamp/polyglot-persistence/postCreateCommand.sh", + "forwardPorts": [27017, 5432, 6379, 2113, 1113], + "portsAttributes": { + "2113": { + "label": "EventStoreDB Admin UI", + "onAutoForward": "notify" + }, + "1113": { + "label": "EventStoreDB API", + "onAutoForward": "silent" + }, + "27017": { + "label": "MongoDB", + "onAutoForward": "notify" + }, + "5432": { + "label": "PostgreSQL", + "onAutoForward": "notify" + }, + "6379": { + "label": "Redis", + "onAutoForward": "notify" + } + }, + "customizations": { + "vscode": { + "settings": { + "extensions.ignoreRecommendations": true, + "telemetry.enableTelemetry": false, + "telemetry.telemetryLevel": "off", + "redhat.telemetry.enabled": false + }, + "extensions": [ + "ms-dotnettools.csharp", + "ms-azuretools.vscode-docker" + ] + }, + "codespaces": { + "openFiles": [] + } + } +} \ No newline at end of file diff --git a/polyglot-persistence/data/init-data.zip b/polyglot-persistence/data/init-data.zip new file mode 100644 index 0000000..59527aa Binary files /dev/null and b/polyglot-persistence/data/init-data.zip differ diff --git a/polyglot-persistence/docker-compose.yml b/polyglot-persistence/docker-compose.yml index be3fbb9..7423764 100644 --- a/polyglot-persistence/docker-compose.yml +++ b/polyglot-persistence/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: mongo: image: mongo:7.0 diff --git a/polyglot-persistence/generate-data.sh b/polyglot-persistence/generate-data.sh new file mode 100644 index 0000000..e69de29 diff --git a/polyglot-persistence/onCreateCommand.sh b/polyglot-persistence/onCreateCommand.sh new file mode 100644 index 0000000..441eb87 --- /dev/null +++ b/polyglot-persistence/onCreateCommand.sh @@ -0,0 +1,24 @@ +docker compose -f /workspaces/developer-bootcamp/polyglot-persistence/docker-compose.yml up -d + +unzip -o /workspaces/developer-bootcamp/polyglot-persistence/data/init-data.zip -d /workspaces/developer-bootcamp/polyglot-persistence/ + +chmod +x /workspaces/developer-bootcamp/polyglot-persistence/tools/Kurrent.Extensions.Commerce/linux-x64/edb-commerce + +# Wait for EventStoreDB to be ready +echo "Waiting for EventStoreDB to be ready..." +max_attempts=30 +attempt=0 +while ! curl -s http://localhost:2113/ > /dev/null; do + attempt=$((attempt+1)) + if [ $attempt -eq $max_attempts ]; then + echo "EventStoreDB failed to start after $max_attempts attempts. Exiting." + exit 1 + fi + echo "Waiting for EventStoreDB to be ready... (attempt $attempt/$max_attempts)" + sleep 2 +done +echo "EventStoreDB is ready." + +/workspaces/developer-bootcamp/polyglot-persistence/tools/Kurrent.Extensions.Commerce/linux-x64/edb-commerce seed-data-set /workspaces/developer-bootcamp/polyglot-persistence/data.json + +dotnet build /workspaces/developer-bootcamp/polyglot-persistence/polyglot-persistence.sln \ No newline at end of file diff --git a/polyglot-persistence/postCreateCommand.sh b/polyglot-persistence/postCreateCommand.sh new file mode 100644 index 0000000..0aa8341 --- /dev/null +++ b/polyglot-persistence/postCreateCommand.sh @@ -0,0 +1,9 @@ +docker compose -f /workspaces/developer-bootcamp/polyglot-persistence/docker-compose.yml up -d + +dotnet run --project /workspaces/developer-bootcamp/polyglot-persistence/DemoWeb & + +dotnet run --project /workspaces/developer-bootcamp/polyglot-persistence/PostgresProjection & + +dotnet run --project /workspaces/developer-bootcamp/polyglot-persistence/RedisProjection & + +dotnet run --project /workspaces/developer-bootcamp/polyglot-persistence/MongoProjection & \ No newline at end of file