File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,21 +43,17 @@ jobs:
4343 type=semver,pattern={{version}}
4444 type=semver,pattern={{major}}.{{minor}}
4545 type=semver,pattern={{major}}
46- type=sha
47-
46+ type=sha
47+
48+ - name : Set up Docker Buildx
49+ uses : docker/setup-buildx-action@v3
50+
4851 - name : Build and push container
49- run : |
50- # Create tag arguments for Docker
51- TAGS=""
52- while IFS= read -r tag; do
53- TAGS="$TAGS -t $tag"
54- done <<< "${{ steps.meta.outputs.tags }}"
55-
56- dotnet publish Web/Web.csproj \
57- --os linux \
58- --arch x64 \
59- -c Release \
60- --self-contained \
61- /p:PublishProfile=DefaultContainer \
62- /p:ContainerRepository=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} \
63- /p:ContainerBuildArgs="$TAGS"
52+ uses : docker/build-push-action@v5
53+ with :
54+ context : .
55+ push : true
56+ tags : ${{ steps.meta.outputs.tags }}
57+ labels : ${{ steps.meta.outputs.labels }}
58+ cache-from : type=gha
59+ cache-to : type=gha,mode=max
Original file line number Diff line number Diff line change 1+ # Build stage
2+ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
3+ WORKDIR /src
4+
5+ # Copy csproj and restore dependencies
6+ COPY ["Web/Web.csproj" , "Web/" ]
7+ RUN dotnet restore "Web/Web.csproj"
8+
9+ # Copy the rest of the source code
10+ COPY . .
11+
12+ # Build and publish
13+ RUN dotnet publish "Web/Web.csproj" -c Release -o /app/publish /p:UseAppHost=false
14+
15+ # Runtime stage
16+ FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
17+ WORKDIR /app
18+ EXPOSE 80
19+ EXPOSE 443
20+
21+ # Copy from build stage
22+ COPY --from=build /app/publish .
23+ ENTRYPOINT ["dotnet" , "Web.dll" ]
You can’t perform that action at this time.
0 commit comments