-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.api
More file actions
50 lines (40 loc) · 2.58 KB
/
Dockerfile.api
File metadata and controls
50 lines (40 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# syntax=docker/dockerfile:1
# =============================================================================
# Stage 1 — Build
# Build context: solution root (GoceTransportApp/)
# =============================================================================
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# -- Solution-level analyser files (StyleCop, Roslyn ruleset) --
COPY Rules.ruleset stylecop.json ./
# -- Copy ONLY .csproj files first for maximum layer-cache reuse on restore --
# Transitive chain: WebApi → Data → (Common, Data.Common, Data.Models)
# WebApi → Services.Data → (Data.Common, Data.Models, Web.ViewModels, Services.Mapping)
COPY GoceTransportApp.Common/GoceTransportApp.Common.csproj GoceTransportApp.Common/
COPY Data/GoceTransportApp.Data.Common/GoceTransportApp.Data.Common.csproj Data/GoceTransportApp.Data.Common/
COPY Data/GoceTransportApp.Data.Models/GoceTransportApp.Data.Models.csproj Data/GoceTransportApp.Data.Models/
COPY Data/GoceTransportApp.Data/GoceTransportApp.Data.csproj Data/GoceTransportApp.Data/
COPY Services/GoceTransportApp.Services.Data/GoceTransportApp.Services.Data.csproj Services/GoceTransportApp.Services.Data/
COPY Services/GoceTransportApp.Services.Mapping/GoceTransportApp.Services.Mapping.csproj Services/GoceTransportApp.Services.Mapping/
COPY Web/GoceTransportApp.Web.ViewModels/GoceTransportApp.Web.ViewModels.csproj Web/GoceTransportApp.Web.ViewModels/
COPY GoceTransportApp.WebApi/GoceTransportApp.WebApi.csproj GoceTransportApp.WebApi/
# -- Restore packages (cached until a .csproj changes) --
RUN dotnet restore "GoceTransportApp.WebApi/GoceTransportApp.WebApi.csproj"
# -- Copy all remaining source code --
COPY . .
# -- Publish release build --
RUN dotnet publish "GoceTransportApp.WebApi/GoceTransportApp.WebApi.csproj" \
-c Release \
-o /app/publish \
--no-restore
# =============================================================================
# Stage 2 — Runtime (minimal ASP.NET image, no SDK)
# =============================================================================
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .
ENV ASPNETCORE_ENVIRONMENT=Production
# Cloud Run инжектира $PORT (default 8080).
# Shell-форма на CMD позволява разгъването на $PORT по runtime.
EXPOSE 8080
CMD exec dotnet GoceTransportApp.WebApi.dll --urls "http://+:${PORT:-8080}"