Skip to content

Instantly share code, notes, and snippets.

@iannbing
Created May 24, 2024 09:33
Show Gist options
  • Save iannbing/6c350cf848b26c0d76616d1e6955d694 to your computer and use it in GitHub Desktop.
Save iannbing/6c350cf848b26c0d76616d1e6955d694 to your computer and use it in GitHub Desktop.
Setup local database with Docker
SA_PASSWORD=YourStrong!Passw0rd
services:
sql_server:
image: mcr.microsoft.com/mssql/server:2022-latest
env_file:
- .env
environment:
- ACCEPT_EULA=Y
ports:
- "1433:1433"
container_name: mssql_server_container
COMPOSE_FILE := database/docker-compose.yml
.DEFAULT_GOAL := help
## -----------------------------------------------------------
## Spin up the SQL Server container for local development.
## -----------------------------------------------------------
.PHONY: help
help:
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
.PHONY: db-up
db-up: ## Start the SQL Server container
docker-compose -f $(COMPOSE_FILE) up -d
.PHONY: db-stop
db-stop: ## Stop the SQL Server container
@echo "Stopping the SQL Server container..."
docker-compose -f $(COMPOSE_FILE) stop
.PHONY: db-down
db-down: ## Stop and remove the SQL Server container
@echo "Stopping and removing the SQL Server container..."
docker-compose -f $(COMPOSE_FILE) down
.PHONY: db-restart
db-restart: ## Restart the SQL Server container
@echo "Restarting the SQL Server container..."
docker-compose -f $(COMPOSE_FILE) restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment