Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 6724bbf

Browse files
feat: azurite persists, database docker files moved
1 parent cbf5775 commit 6724bbf

File tree

6 files changed

+40
-52
lines changed

6 files changed

+40
-52
lines changed

SetUp/Database/Dockerfile

Lines changed: 0 additions & 22 deletions
This file was deleted.

SetUp/Database/db-setup-entrypoint.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

compose.yaml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
services:
2-
### ✅ API (Azure Functions in .NET 9) ###
32
api:
43
container_name: "api"
54
build:
@@ -17,7 +16,7 @@ services:
1716
ports:
1817
- "${API_PORT}:80"
1918
healthcheck:
20-
test: ["CMD", "curl", "-f", "http://localhost:80/api/health"]
19+
test: ["CMD-SHELL", "curl -f http://localhost:80/api/health || exit 1"]
2120
interval: 30s
2221
timeout: 10s
2322
retries: 3
@@ -30,7 +29,6 @@ services:
3029
networks:
3130
- backend
3231

33-
### ✅ Azurite (Azure Storage Emulator) ###
3432
azurite:
3533
container_name: "azurite"
3634
image: mcr.microsoft.com/azure-storage/azurite:latest
@@ -41,17 +39,16 @@ services:
4139
- "${AZURITE_QUEUE_PORT}:10001"
4240
- "${AZURITE_TABLE_PORT}:10002"
4341
healthcheck:
44-
test: [ "CMD-SHELL", "/bin/sh -c 'nc -z 127.0.0.1 10000 || exit 1'" ]
42+
test: ["CMD-SHELL", "/bin/sh -c 'nc -z 127.0.0.1 10000 || exit 1'"]
4543
interval: 10s
4644
timeout: 5s
4745
retries: 10
48-
start_period: 10s
46+
start_period: 15s
4947
volumes:
5048
- azurite-data:/data
5149
networks:
5250
- backend
5351

54-
### ✅ Database (SQL Server) ###
5552
db:
5653
container_name: "db"
5754
image: mcr.microsoft.com/mssql/server:2022-latest
@@ -65,21 +62,35 @@ services:
6562
volumes:
6663
- db-data:/var/opt/mssql
6764
healthcheck:
68-
test: [ "CMD-SHELL", "pgrep -x sqlservr || exit 1" ]
69-
interval: 15s
70-
timeout: 15s
71-
retries: 5
72-
start_period: 30s
65+
test: ["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P \"${DATABASE_PASSWORD}\" -Q \"SELECT 1;\" || exit 1"]
66+
interval: 20s
67+
timeout: 10s
68+
retries: 6
69+
start_period: 60s
70+
networks:
71+
- backend
72+
73+
db-setup:
74+
container_name: "db-setup"
75+
build:
76+
context: ./database
77+
dockerfile: Dockerfile
78+
restart: "no"
79+
environment:
80+
DATABASE_PASSWORD: "${DATABASE_PASSWORD}"
81+
depends_on:
82+
db:
83+
condition: service_healthy
7384
networks:
7485
- backend
7586

7687
networks:
7788
backend:
7889
name: backend-network
7990
driver: bridge
80-
8191
volumes:
8292
azurite-data:
8393
name: azurite-data
8494
db-data:
8595
name: db-data
96+
driver: local

database/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM mcr.microsoft.com/mssql-tools
2+
WORKDIR /scripts
3+
COPY create_database_statement.sql .
4+
COPY db-setup-entrypoint.sh .
5+
RUN chmod +x ./db-setup-entrypoint.sh
6+
ENTRYPOINT ["/scripts/db-setup-entrypoint.sh"]
File renamed without changes.

database/db-setup-entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
echo "🔧 Starting DB setup..."
3+
echo "📡 Connecting to SQL Server at db..."
4+
until /opt/mssql-tools/bin/sqlcmd -S db -U SA -P "${DATABASE_PASSWORD}" -Q "SELECT 1;" > /dev/null 2>&1
5+
do
6+
echo "⏳ Waiting for SQL Server..."
7+
sleep 5
8+
done
9+
echo "✅ SQL Server is ready."
10+
/opt/mssql-tools/bin/sqlcmd -S db -U SA -P "${DATABASE_PASSWORD}" -d master -i create_database_statement.sql
11+
echo "✅ Database setup completed."

0 commit comments

Comments
 (0)