Merge pull request #374 from meysamhadeli/refactor/refactor-docker-files

refactor: refactor dockerfiles
This commit is contained in:
Meysam Hadeli 2026-02-26 23:50:46 +03:30 committed by GitHub
commit d99d1a9a9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 144 additions and 444 deletions

View File

@ -355,7 +355,7 @@ services:
args:
Version: "1"
context: ../../
dockerfile: src/ApiGateway/dev.Dockerfile
dockerfile: src/ApiGateway/Dockerfile
container_name: api-gateway
ports:
- "5001:80"
@ -382,7 +382,7 @@ services:
args:
Version: "1"
context: ../../
dockerfile: src/Services/Flight/dev.Dockerfile
dockerfile: src/Services/Flight/Dockerfile
container_name: flight
ports:
- 5004:80
@ -408,7 +408,7 @@ services:
args:
Version: "1"
context: ../../
dockerfile: src/Services/Identity/dev.Dockerfile
dockerfile: src/Services/Identity/Dockerfile
container_name: identity
ports:
- 6005:80
@ -435,7 +435,7 @@ services:
args:
Version: "1"
context: ../../
dockerfile: src/Services/Passenger/dev.Dockerfile
dockerfile: src/Services/Passenger/Dockerfile
container_name: passenger
ports:
- 6012:80
@ -462,7 +462,7 @@ services:
args:
Version: "1"
context: ../../
dockerfile: src/Services/Booking/dev.Dockerfile
dockerfile: src/Services/Booking/Dockerfile
container_name: booking
ports:
- 6010:80

View File

@ -1,46 +1,38 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
# ---------- Build Stage ----------
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Copy solution-level files
COPY .editorconfig .
COPY global.json .
COPY Directory.Build.props .
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./building-blocks/
COPY ./src/ApiGateway/src/ApiGateway.csproj ./src/ApiGateway/src/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Copy project files first (better Docker caching)
COPY src/BuildingBlocks/BuildingBlocks.csproj src/BuildingBlocks/
COPY src/ApiGateway/src/ApiGateway.csproj src/ApiGateway/src/
COPY src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN dotnet restore ./src/ApiGateway/src/ApiGateway.csproj
# Restore dependencies
RUN dotnet restore src/ApiGateway/src/ApiGateway.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/ApiGateway/src ./src/ApiGateway/src/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Copy the rest of the source code
COPY src ./src
# Build project with Release configuration
# and no restore, as we did it already
# Publish (build included)
RUN dotnet publish src/ApiGateway/src/ApiGateway.csproj \
-c Release \
-o /app/publish \
--no-restore
RUN ls
RUN dotnet build -c Release --no-restore ./src/ApiGateway/src/ApiGateway.csproj
# ---------- Runtime Stage ----------
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
WORKDIR /src/ApiGateway/src
COPY --from=build /app/publish .
# Publish project to output folder
# and no build, as we did it already
RUN dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/ApiGateway/src/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
ENV ASPNETCORE_URLS=http://+:80
ENV ASPNETCORE_ENVIRONMENT=docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "ApiGateway.dll"]
ENTRYPOINT ["dotnet", "ApiGateway.dll"]

View File

@ -1,48 +0,0 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./building-blocks/
COPY ./src/ApiGateway/src/ApiGateway.csproj ./src/ApiGateway/src/
# Restore nuget packages
RUN --mount=type=cache,id=gateway_nuget,target=/root/.nuget/packages \
dotnet restore ./src/ApiGateway/src/ApiGateway.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/ApiGateway/src ./src/ApiGateway/src/
# Build project with Release configuration
# and no restore, as we did it already
RUN ls
RUN --mount=type=cache,id=gateway_nuget,target=/root/.nuget/packages \
dotnet build -c Release --no-restore ./src/ApiGateway/src/ApiGateway.csproj
WORKDIR /src/ApiGateway/src
# Publish project to output folder
# and no build, as we did it already
RUN --mount=type=cache,id=gateway_nuget,target=/root/.nuget/packages \
dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/ApiGateway/src/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "ApiGateway.dll"]

View File

@ -1,48 +1,39 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
# ---------- Build Stage ----------
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Copy solution-level files
COPY .editorconfig .
COPY global.json .
COPY Directory.Build.props .
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Booking/src/Booking/Booking.csproj ./src/Services/Booking/src/Booking/
COPY ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./src/Services/Booking/src/Booking.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Copy project files first (for Docker layer caching)
COPY src/BuildingBlocks/BuildingBlocks.csproj src/BuildingBlocks/
COPY src/Services/Booking/src/Booking/Booking.csproj src/Services/Booking/src/Booking/
COPY src/Services/Booking/src/Booking.Api/Booking.Api.csproj src/Services/Booking/src/Booking.Api/
COPY src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN dotnet restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj
# Restore dependencies
RUN dotnet restore src/Services/Booking/src/Booking.Api/Booking.Api.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Booking/src/Booking/ ./src/Services/Booking/src/Booking/
COPY ./src/Services/Booking/src/Booking.Api/ ./src/Services/Booking/src/Booking.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Copy the rest of the source
COPY src ./src
# Build project with Release configuration
# and no restore, as we did it already
# Publish (build included)
RUN dotnet publish src/Services/Booking/src/Booking.Api/Booking.Api.csproj \
-c Release \
-o /app/publish \
--no-restore
RUN ls
RUN dotnet build -c Release --no-restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj
# ---------- Runtime Stage ----------
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
WORKDIR /src/Services/Booking/src/Booking.Api
COPY --from=build /app/publish .
# Publish project to output folder
# and no build, as we did it already
RUN dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Booking/src/Booking.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
ENV ASPNETCORE_URLS=http://+:80
ENV ASPNETCORE_ENVIRONMENT=docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Booking.Api.dll"]
ENTRYPOINT ["dotnet", "Booking.Api.dll"]

View File

@ -1,51 +0,0 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Booking/src/Booking/Booking.csproj ./src/Services/Booking/src/Booking/
COPY ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./src/Services/Booking/src/Booking.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages \
dotnet restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Booking/src/Booking/ ./src/Services/Booking/src/Booking/
COPY ./src/Services/Booking/src/Booking.Api/ ./src/Services/Booking/src/Booking.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Build project with Release configuration
# and no restore, as we did it already
RUN ls
RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages\
dotnet build -c Release --no-restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj
WORKDIR /src/Services/Booking/src/Booking.Api
# Publish project to output folder
# and no build, as we did it already
RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages\
dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Booking/src/Booking.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Booking.Api.dll"]

View File

@ -1,49 +1,39 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
# ---------- Build Stage ----------
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Copy solution-level files
COPY .editorconfig .
COPY global.json .
COPY Directory.Build.props .
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Flight/src/Flight/Flight.csproj ./src/Services/Flight/src/Flight/
COPY ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./src/Services/Flight/src/Flight.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Copy project files first (better layer caching)
COPY src/BuildingBlocks/BuildingBlocks.csproj src/BuildingBlocks/
COPY src/Services/Flight/src/Flight/Flight.csproj src/Services/Flight/src/Flight/
COPY src/Services/Flight/src/Flight.Api/Flight.Api.csproj src/Services/Flight/src/Flight.Api/
COPY src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN dotnet restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj
# Restore dependencies
RUN dotnet restore src/Services/Flight/src/Flight.Api/Flight.Api.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Flight/src/Flight/ ./src/Services/Flight/src/Flight/
COPY ./src/Services/Flight/src/Flight.Api/ ./src/Services/Flight/src/Flight.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Copy remaining source code
COPY src ./src
# Build project with Release configuration
# and no restore, as we did it already
# Publish (build included)
RUN dotnet publish src/Services/Flight/src/Flight.Api/Flight.Api.csproj \
-c Release \
-o /app/publish \
--no-restore
RUN ls
RUN dotnet build -c Release --no-restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj
# ---------- Runtime Stage ----------
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
WORKDIR /src/Services/Flight/src/Flight.Api
COPY --from=build /app/publish .
# Publish project to output folder
# and no build, as we did it already
RUN dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Flight/src/Flight.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
ENV ASPNETCORE_URLS=http://+:80
ENV ASPNETCORE_ENVIRONMENT=docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Flight.Api.dll"]
ENTRYPOINT ["dotnet", "Flight.Api.dll"]

View File

@ -1,52 +0,0 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Flight/src/Flight/Flight.csproj ./src/Services/Flight/src/Flight/
COPY ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./src/Services/Flight/src/Flight.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \
dotnet restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Flight/src/Flight/ ./src/Services/Flight/src/Flight/
COPY ./src/Services/Flight/src/Flight.Api/ ./src/Services/Flight/src/Flight.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Build project with Release configuration
# and no restore, as we did it already
RUN ls
RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \
dotnet build -c Release --no-restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj
WORKDIR /src/Services/Flight/src/Flight.Api
# Publish project to output folder
# and no build, as we did it already
RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \
dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Flight/src/Flight.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Flight.Api.dll"]

View File

@ -1,49 +1,39 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
# ---------- Build Stage ----------
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Setup working directory for the project
WORKDIR /
# Copy solution-level files
COPY .editorconfig .
COPY global.json .
COPY Directory.Build.props .
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Copy project files first (for better Docker layer caching)
COPY src/BuildingBlocks/BuildingBlocks.csproj src/BuildingBlocks/
COPY src/Services/Identity/src/Identity/Identity.csproj src/Services/Identity/src/Identity/
COPY src/Services/Identity/src/Identity.Api/Identity.Api.csproj src/Services/Identity/src/Identity.Api/
COPY src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj src/Aspire/src/ServiceDefaults/
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Identity/src/Identity/Identity.csproj ./src/Services/Identity/src/Identity/
COPY ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./src/Services/Identity/src/Identity.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Restore dependencies
RUN dotnet restore src/Services/Identity/src/Identity.Api/Identity.Api.csproj
# Restore nuget packages
RUN dotnet restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj
# Copy remaining source code
COPY src ./src
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Identity/src/Identity/ ./src/Services/Identity/src/Identity/
COPY ./src/Services/Identity/src/Identity.Api/ ./src/Services/Identity/src/Identity.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Publish (build included, no separate build step needed)
RUN dotnet publish src/Services/Identity/src/Identity.Api/Identity.Api.csproj \
-c Release \
-o /app/publish \
--no-restore
# Build project with Release configuration
# and no restore, as we did it already
# ---------- Runtime Stage ----------
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
RUN ls
RUN dotnet build -c Release --no-restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj
COPY --from=build /app/publish .
WORKDIR /src/Services/Identity/src/Identity.Api
# Publish project to output folder
# and no build, as we did it already
RUN dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Identity/src/Identity.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
ENV ASPNETCORE_URLS=http://+:80
ENV ASPNETCORE_ENVIRONMENT=docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Identity.Api.dll"]
ENTRYPOINT ["dotnet", "Identity.Api.dll"]

View File

@ -1,52 +0,0 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
# Setup working directory for the project
WORKDIR /
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Identity/src/Identity/Identity.csproj ./src/Services/Identity/src/Identity/
COPY ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./src/Services/Identity/src/Identity.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \
dotnet restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Identity/src/Identity/ ./src/Services/Identity/src/Identity/
COPY ./src/Services/Identity/src/Identity.Api/ ./src/Services/Identity/src/Identity.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Build project with Release configuration
# and no restore, as we did it already
RUN ls
RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \
dotnet build -c Release --no-restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj
WORKDIR /src/Services/Identity/src/Identity.Api
# Publish project to output folder
# and no build, as we did it already
RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \
dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Identity/src/Identity.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Identity.Api.dll"]

View File

@ -1,48 +1,39 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
# ---------- Build Stage ----------
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Copy solution-level files
COPY .editorconfig .
COPY global.json .
COPY Directory.Build.props .
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Passenger/src/Passenger/Passenger.csproj ./src/Services/Passenger/src/Passenger/
COPY ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./src/Services/Passenger/src/Passenger.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Copy project files first (better Docker layer caching)
COPY src/BuildingBlocks/BuildingBlocks.csproj src/BuildingBlocks/
COPY src/Services/Passenger/src/Passenger/Passenger.csproj src/Services/Passenger/src/Passenger/
COPY src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj src/Services/Passenger/src/Passenger.Api/
COPY src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN dotnet restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj
# Restore dependencies
RUN dotnet restore src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Passenger/src/Passenger/ ./src/Services/Passenger/src/Passenger/
COPY ./src/Services/Passenger/src/Passenger.Api/ ./src/Services/Passenger/src/Passenger.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Copy remaining source code
COPY src ./src
# Build project with Release configuration
# and no restore, as we did it already
# Publish (build included)
RUN dotnet publish src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj \
-c Release \
-o /app/publish \
--no-restore
RUN ls
RUN dotnet build -c Release --no-restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj
# ---------- Runtime Stage ----------
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
WORKDIR /src/Services/Passenger/src/Passenger.Api
COPY --from=build /app/publish .
# Publish project to output folder
# and no build, as we did it already
RUN dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Passenger/src/Passenger.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
ENV ASPNETCORE_URLS=http://+:80
ENV ASPNETCORE_ENVIRONMENT=docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Passenger.Api.dll"]
ENTRYPOINT ["dotnet", "Passenger.Api.dll"]

View File

@ -1,51 +0,0 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder
WORKDIR /
COPY ./.editorconfig ./
COPY ./global.json ./
COPY ./Directory.Build.props ./
# Setup working directory for the project
COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./src/BuildingBlocks/
COPY ./src/Services/Passenger/src/Passenger/Passenger.csproj ./src/Services/Passenger/src/Passenger/
COPY ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./src/Services/Passenger/src/Passenger.Api/
COPY ./src/Aspire/src/ServiceDefaults/ServiceDefaults.csproj ./src/Aspire/src/ServiceDefaults/
# Restore nuget packages
RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \
dotnet restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj
# Copy project files
COPY ./src/BuildingBlocks ./src/BuildingBlocks/
COPY ./src/Services/Passenger/src/Passenger/ ./src/Services/Passenger/src/Passenger/
COPY ./src/Services/Passenger/src/Passenger.Api/ ./src/Services/Passenger/src/Passenger.Api/
COPY ./src/Aspire/src/ServiceDefaults/ ./src/Aspire/src/ServiceDefaults/
# Build project with Release configuration
# and no restore, as we did it already
RUN ls
RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \
dotnet build -c Release --no-restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj
WORKDIR /src/Services/Passenger/src/Passenger.Api
# Publish project to output folder
# and no build, as we did it already
RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \
dotnet publish -c Release --no-build -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Setup working directory for the project
WORKDIR /
COPY --from=builder /src/Services/Passenger/src/Passenger.Api/out .
ENV ASPNETCORE_URLS https://*:443, http://*:80
ENV ASPNETCORE_ENVIRONMENT docker
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "Passenger.Api.dll"]