Skip to content

Commit

Permalink
Merge pull request #3 from redbadger/inventory-service-scaffolding
Browse files Browse the repository at this point in the history
Inventory service implementation
  • Loading branch information
olliebatch authored Dec 21, 2023
2 parents c87ead2 + f35e1de commit 007bac7
Show file tree
Hide file tree
Showing 22 changed files with 2,937 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"rust-containers-k8s/notification-service/Cargo.toml",
"rust-containers-k8s/order-service/Cargo.toml",
"rust-containers-k8s/product-service/Cargo.toml"
]
],
}
5 changes: 5 additions & 0 deletions rust-containers-k8s/database/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -euo pipefail

docker compose down --rmi local --volumes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -euo pipefail

function create_user_and_database() {
local database=$1
echo " Creating user and database '$database'"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER $database WITH PASSWORD '$POSTGRES_PASSWORD';
CREATE DATABASE $database;
ALTER DATABASE $database OWNER TO $database;
EOSQL
}

if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES"
for db in $(echo "$POSTGRES_MULTIPLE_DATABASES" | tr ',' ' '); do
create_user_and_database "$db"
done
echo "Multiple databases created"
fi
5 changes: 5 additions & 0 deletions rust-containers-k8s/database/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -euo pipefail

docker compose down
5 changes: 5 additions & 0 deletions rust-containers-k8s/database/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -euo pipefail

docker compose up -d
10 changes: 5 additions & 5 deletions rust-containers-k8s/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
version: '3.8'
version: "3.8"

services:
db:
postgres:
image: postgres:16.1
restart: always

volumes:
- .//database/docker-postgresql-multiple-databases:/docker-entrypoint-initdb.d
environment:
POSTGRES_MULTIPLE_DATABASES: '"order-service", "inventory-service"'
POSTGRES_PASSWORD: commerce
POSTGRES_USER: commerce
POSTGRES_DB: order-service
ports:
- 5432:5432
2 changes: 2 additions & 0 deletions rust-containers-k8s/inventory-service/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export PORT=
export DATABASE_URL=
Loading

0 comments on commit 007bac7

Please sign in to comment.