SCM_Lecture05_Lab[2]
SCM_Lecture05_Lab[2]
- Log in to GitHub and create a new repository for your project. Name it according to the
application’s purpose (e.g., AdventureWorksMicroservices).
- Add a descriptive README.md to the repository with sections for project objectives,
technology stack, setup instructions, and architecture overview.
cd AdventureWorksMicroservices
git init
- Create .gitignore to exclude unnecessary files from version control (e.g., bin/, obj/):
bin/
obj/
*.log
*.db
git add .
git commit -m 'Initialize project with README and .gitignore'
USE [master];
CREATE DATABASE AdventureWorks
ON (FILENAME = 'C:\Path\To\AdventureWorks.mdf')
FOR ATTACH;
- Open Visual Studio and create a new ASP.NET Core Web API project.
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=AdventureWorks;User
Id=<username>;Password=<password>;"
}
- Implement CRUD operations for selected tables using Entity Framework Core.
2. Create Dockerfiles:
- Dockerfile for MS SQL Server: Pull the MS SQL Server image if using Docker:
docker pull mcr.microsoft.com/mssql/server
version: '3.8'
services:
sqlserver:
image: mcr.microsoft.com/mssql/server
environment:
SA_PASSWORD: "YourStrong@Passw0rd"
ACCEPT_EULA: "Y"
ports:
- "1433:1433"
api:
build: .
depends_on:
- sqlserver
environment:
ConnectionStrings__DefaultConnection:
"Server=sqlserver;Database=AdventureWorks;User
Id=sa;Password=YourStrong@Passw0rd;"
ports:
- "8080:80"
docker-compose up --build
- Create a Jenkinsfile with stages: Build, Docker Build, and Deploy to Staging:
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
sh 'dotnet build YourApiProjectName.sln'
}
}
}
stage('Docker Build') {
steps {
script {
sh 'docker build -t your-api-image-name .'
}
}
}
stage('Deploy to Staging') {
steps {
script {
sh 'docker-compose up --build -d'
}
}
}
}
}
Step 5: Documentation
1. Document Architecture and Setup:
2. API Documentation:
- Use Swagger for API documentation and provide interactive API specs.
- Include setup instructions in the README.md.