-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (54 loc) · 3 KB
/
Dockerfile
File metadata and controls
69 lines (54 loc) · 3 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
# Base image for running both services
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080 8081
# Build stage for all projects
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# Copy all project files (including referenced ones)
COPY ["Frontend/Frontend.csproj", "Frontend/"]
COPY ["Frontend.Api/Frontend.Api.csproj", "Frontend.Api/"]
COPY ["Dto.Shared/Dto.Shared.csproj", "Dto.Shared/"]
COPY ["Interfaces.Shared/Interfaces.Shared.csproj", "Interfaces.Shared/"]
COPY ["Frontend.Client/Frontend.Client.csproj", "Frontend.Client/"]
# Restore dependencies for all projects
RUN dotnet restore "./Frontend/Frontend.csproj"
RUN dotnet restore "./Frontend.Api/Frontend.Api.csproj"
RUN dotnet restore "./Dto.Shared/Dto.Shared.csproj"
RUN dotnet restore "./Interfaces.Shared/Interfaces.Shared.csproj"
RUN dotnet restore "./Frontend.Client/Frontend.Client.csproj"
# Copy the source code for all projects
COPY . .
# Build all projects
WORKDIR "/src/Frontend"
RUN dotnet build "./Frontend.csproj" -c $BUILD_CONFIGURATION -o /app/build
WORKDIR "/src/Frontend.Api"
RUN dotnet build "./Frontend.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
WORKDIR "/src/Dto.Shared"
RUN dotnet build "./Dto.Shared.csproj" -c $BUILD_CONFIGURATION -o /app/build
WORKDIR "/src/Interfaces.Shared"
RUN dotnet build "./Interfaces.Shared.csproj" -c $BUILD_CONFIGURATION -o /app/build
WORKDIR "/src/Frontend.Client"
RUN dotnet build "./Frontend.Client.csproj" -c $BUILD_CONFIGURATION -o /app/build
WORKDIR /src
# Publish all projects
FROM build AS publish
RUN dotnet publish "Frontend/Frontend.csproj" -c $BUILD_CONFIGURATION -o /app/publish/Frontend /p:UseAppHost=false
RUN dotnet publish "./Frontend.Api/Frontend.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish/Frontend.Api /p:UseAppHost=false
RUN dotnet publish "./Dto.Shared/Dto.Shared.csproj" -c $BUILD_CONFIGURATION -o /app/publish/Dto.Shared /p:UseAppHost=false
RUN dotnet publish "./Interfaces.Shared/Interfaces.Shared.csproj" -c $BUILD_CONFIGURATION -o /app/publish/Interfaces.Shared /p:UseAppHost=false
RUN dotnet publish "./Frontend.Client/Frontend.Client.csproj" -c $BUILD_CONFIGURATION -o /app/publish/Frontend.Client /p:UseAppHost=false
# Final image combining all projects
FROM base AS final
WORKDIR /app
# Copy the published projects into the final image
COPY --from=publish /app/publish/Frontend /app/Frontend
COPY --from=publish /app/publish/Frontend.Api /app/Frontend.Api
COPY --from=publish /app/publish/Dto.Shared /app/Dto.Shared
COPY --from=publish /app/publish/Interfaces.Shared /app/Interfaces.Shared
COPY --from=publish /app/publish/Frontend.Client /app/Frontend.Client
# Start both services (assuming Frontend.Api is the API and Frontend is the frontend client)
ENTRYPOINT ["sh", "-c", "dotnet Frontend.Api/Frontend.Api.dll & dotnet Frontend/Frontend.dll"]