Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MSSQL_HOST=mssql_server_local # must be mssql_server_local service defined in mssql/docker-compose.yml
MSSQL_PORT=1433
MSSQL_DB=app_pizza
MSSQL_SA_PASSWORD=example_123
MSSQL_SA_USER=sa
ACCEPT_EULA=Y
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mssql_server_local
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
volumes:
# the name of a volume to be used to store the database folder
# the same is used at "- ./app_x_mssql_data:/var/lib/mssql"
app_pizza_mssql_data:
driver: local
services:
initialize-database:
image: mcr.microsoft.com/mssql-tools:latest
container_name: initialize-database
restart: no
command: "/opt/mssql-tools/bin/sqlcmd -C -S ${MSSQL_HOST} -U ${MSSQL_SA_USER} -P ${MSSQL_SA_PASSWORD} -i /tmp/mssql-init.sql"
depends_on:
mssql_server_local:
condition: service_healthy
volumes:
- ./mssql/mssql-init.sql:/tmp/mssql-init.sql
env_file:
- .env

mssql_server_local:
image: mcr.microsoft.com/mssql/server
container_name: mssql_server_local
restart: always
ports:
- ${MSSQL_PORT}:1433
expose:
# Opens port 3306 on the container
- ${MSSQL_PORT}
env_file:
- .env
volumes:
# the location of the database folder
- ./mssql_server_local:/var/opt/mssql
healthcheck:
test:
[
"CMD-SHELL",
"/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U ${MSSQL_SA_USER} -P ${MSSQL_SA_PASSWORD} -Q 'SELECT 1' || exit 1",
]
interval: 10s
retries: 10
start_period: 10s
timeout: 3s

app_pizza:
container_name: app_pizza
build:
context: ./pizza_shop/
dockerfile: ./Dockerfile.dev
depends_on:
mssql_server_local:
condition: service_healthy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP DATABASE IF EXISTS app_pizza_shop

CREATE DATABASE app_pizza_shop
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
echo "Starting up the sytem. Please wait until the script confirms the system is running."
docker compose up -d
echo "The System is now ready."
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
echo "Stopping the sytem. Please wait until the script confirms the system is switch off."
docker compose down
echo "The System has shutdown. Come again soon! :)"
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM mcr.microsoft.com/devcontainers/dotnet:8.0

WORKDIR /pizza_shop

COPY . .

RUN dotnet tool install --global dotnet-ef --version 8.0.0

ENV PATH="$PATH:/root/.dotnet/tools"
ENV PATH="$PATH:/root/.dotnet/tools"

ENTRYPOINT [ "./entry_point.dev.sh" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
dotnet ef database update

dotnet run
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public class PizzaShopContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// Never hard code in PROD of-course
optionsBuilder.UseSqlServer("Server=localhost,1433; Database=PizzaShop; User Id=sa; Password=example_123; Encrypt=false; TrustServerCertificate=true; MultipleActiveResultSets=true;");
optionsBuilder.UseSqlServer("Server=mssql_server_local,1433; Database=app_pizza_shop; User Id=sa; Password=example_123; Encrypt=false; TrustServerCertificate=true; MultipleActiveResultSets=true;");
}
}
1 change: 1 addition & 0 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

- .NET:
- readings:
- https://learn.microsoft.com/en-us/dotnet/fundamentals/
- ecosystem/0_dotnet.txt
- course schedule:
-
Expand Down