Skip to content

Commit 4a41aa9

Browse files
committed
Refactor Dockerfile to use .NET SDK 8.0 and ASP.NET Core runtime 8.0
1 parent 77d57db commit 4a41aa9

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

.github/workflows/dotnet.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
# This workflow will build a .NET project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3-
4-
name: .NET
1+
name: .NET CI
52

63
on:
74
push:
8-
branches: [ "main" ]
5+
branches: [ main ]
6+
paths: src/Application/**
97
pull_request:
10-
branches: [ "main" ]
11-
8+
branches: [ main ]
9+
paths: src/Application/**
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
1212
jobs:
1313
build:
1414

1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v3
1919
- name: Setup .NET
20-
uses: actions/setup-dotnet@v4
21-
with:
22-
dotnet-version: 8.0.x
20+
uses: actions/setup-dotnet@v3
21+
2322
- name: Restore dependencies
24-
run: dotnet restore
23+
run: dotnet restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
2524
- name: Build
26-
run: dotnet build --no-restore
25+
run: dotnet build --no-restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
2726
- name: Test
28-
run: dotnet test --no-build --verbosity normal
27+
run: dotnet test --no-build --verbosity normal ./src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj

Solution/Exercise-03/Task-3/dotnet-deploy-1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ jobs:
2525
run: dotnet build --no-restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
2626
- name: Test
2727
run: dotnet test --no-build --verbosity normal ./src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
28+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Use the official .NET SDK image as the base image
2+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Copy the project file and restore dependencies
8+
COPY *.csproj ./
9+
RUN dotnet restore
10+
11+
# Copy the remaining source code
12+
COPY . ./
13+
14+
# Build the application
15+
RUN dotnet publish -c Release -o out
16+
17+
# Use the official ASP.NET Core runtime image as the base image
18+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
19+
20+
# Set the working directory inside the container
21+
WORKDIR /app
22+
23+
# Copy the published output from the build stage
24+
COPY --from=build /app/out ./
25+
26+
# Set the environment variable
27+
ENV ASPNETCORE_HTTP_PORTS=80
28+
29+
# Set the entry point of the application
30+
ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"]

0 commit comments

Comments
 (0)