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

Commit 06f1928

Browse files
feat: database creation
1 parent fabcd19 commit 06f1928

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

compose.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
azurite:
2626
condition: service_healthy
2727
db:
28-
condition: service_healthy
28+
condition: service_started
2929
networks:
3030
- backend
3131

@@ -61,12 +61,12 @@ services:
6161
- "1433:1433"
6262
volumes:
6363
- db-data:/var/opt/mssql
64-
healthcheck:
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
64+
# healthcheck:
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
7070
networks:
7171
- backend
7272

@@ -80,7 +80,7 @@ services:
8080
DATABASE_PASSWORD: "${DATABASE_PASSWORD}"
8181
depends_on:
8282
db:
83-
condition: service_healthy
83+
condition: service_started
8484
networks:
8585
- backend
8686

database/Dockerfile

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
# Use official Microsoft SQL Server image as base
2-
FROM mcr.microsoft.com/mssql/server:2022-latest
1+
FROM mcr.microsoft.com/mssql-tools
32

4-
# Switch to root to change file permissions
5-
USER root
6-
7-
# Copy the setup script and SQL file to /database inside the container
8-
COPY db-setup-entrypoint.sh /database/db-setup-entrypoint.sh
9-
COPY create_database_statement.sql /database/create_database_statement.sql
10-
11-
# Make sure the entrypoint script is executable
3+
WORKDIR /database
4+
COPY . /database
125
RUN chmod +x /database/db-setup-entrypoint.sh
13-
14-
# Switch back to the default non-root SQL Server user
15-
USER mssql
16-
17-
# Run the entrypoint script when the container starts
186
ENTRYPOINT ["/database/db-setup-entrypoint.sh"]

database/create_database_statement.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ GO
44
IF NOT EXISTS (
55
SELECT name
66
FROM sys.databases
7-
WHERE name = N'PathwayCoordinator'
7+
WHERE name = N'Test'
88
)
9-
CREATE DATABASE [PathwayCoordinator];
9+
CREATE DATABASE [Test];
1010
GO
1111

1212
IF SERVERPROPERTY('ProductVersion') > '12'
13-
ALTER DATABASE [PathwayCoordinator] SET QUERY_STORE = ON;
13+
ALTER DATABASE [Test] SET QUERY_STORE = ON;
1414
GO

database/db-setup-entrypoint.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
#!/bin/bash
22
echo "🔧 Starting DB setup..."
33

4-
# Verify that the script is executable
5-
if [ ! -x /database/db-setup-entrypoint.sh ]; then
6-
echo "❌ Entry point script is not executable"
7-
exit 1
8-
fi
9-
10-
# Verify the content of the script is present and not empty
11-
echo "📄 Content of the script:"
12-
cat /database/db-setup-entrypoint.sh
13-
144
# Check if the SQL script exists
155
if [ ! -f /database/create_database_statement.sql ]; then
166
echo "❌ SQL script not found!"

0 commit comments

Comments
 (0)