Skip to content

Commit 8359bcb

Browse files
author
sonu7552
committed
Added Dockerfile, Compose, and GitHub Actions pipeline
1 parent c23ba83 commit 8359bcb

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# STAGE 1: Build
2+
# We switched from 'dotnet/core/sdk:3.1' to 'dotnet/sdk:5.0'
3+
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
4+
WORKDIR /app
5+
6+
# 1. Copy the project files
7+
COPY src/AspnetRun.Core/*.csproj ./src/AspnetRun.Core/
8+
COPY src/AspnetRun.Application/*.csproj ./src/AspnetRun.Application/
9+
COPY src/AspnetRun.Infrastructure/*.csproj ./src/AspnetRun.Infrastructure/
10+
COPY src/AspnetRun.Web/*.csproj ./src/AspnetRun.Web/
11+
12+
# 2. Restore dependencies
13+
RUN dotnet restore src/AspnetRun.Web/AspnetRun.Web.csproj
14+
15+
# 3. Copy the rest of the source code
16+
COPY src/ ./src/
17+
18+
# 4. Build and Publish
19+
WORKDIR /app/src/AspnetRun.Web
20+
RUN dotnet publish -c Release -o /app/publish
21+
22+
# STAGE 2: Runtime
23+
# We switched from 'dotnet/core/aspnet:3.1' to 'dotnet/aspnet:5.0'
24+
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
25+
WORKDIR /app
26+
COPY --from=build /app/publish .
27+
EXPOSE 80
28+
ENTRYPOINT ["dotnet", "AspnetRun.Web.dll"]

docker-compose.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '3.8'
2+
3+
services:
4+
# 1. THE WEB APPLICATION
5+
aspnetrun-web:
6+
image: aspnetrun-web
7+
build:
8+
context: .
9+
dockerfile: Dockerfile
10+
ports:
11+
# Maps port 80 inside the container to port 8000 on your machine
12+
- "8000:80"
13+
environment:
14+
- ASPNETCORE_ENVIRONMENT=Production
15+
# This overrides the appsettings.json connection string
16+
# 'db' refers to the service name below
17+
- ConnectionStrings__AspnetRunConnection=Server=db;Database=AspnetRunDb;User Id=sa;Password=Password@12345;MultipleActiveResultSets=true
18+
depends_on:
19+
- db
20+
21+
# 2. THE SQL SERVER DATABASE
22+
db:
23+
image: mcr.microsoft.com/mssql/server:2019-latest
24+
environment:
25+
# SQL Server requires a strong password (Capital, lowercase, number, symbol)
26+
- SA_PASSWORD=Password@12345
27+
- ACCEPT_EULA=Y
28+
ports:
29+
- "1433:1433"

0 commit comments

Comments
 (0)