From a70320b7051e587564ce207a14dd327d44d82c8b Mon Sep 17 00:00:00 2001 From: Pc Date: Fri, 24 Feb 2023 02:07:50 +0330 Subject: [PATCH] chore: Update Dockerfiles --- .../docker-compose/docker-compose.yaml | 10 ++-- src/ApiGateway/Dockerfile | 9 ++-- src/ApiGateway/dev.Dockerfile | 45 ++++++++++++++++++ src/ApiGateway/src/appsettings.docker.json | 25 ++++++++-- src/ApiGateway/src/appsettings.json | 6 ++- src/Services/Booking/Dockerfile | 9 ++-- src/Services/Booking/dev.Dockerfile | 46 ++++++++++++++++++ .../src/Booking.Api/appsettings.docker.json | 4 +- .../Booking/src/Booking.Api/appsettings.json | 5 +- src/Services/Flight/Dockerfile | 9 ++-- src/Services/Flight/dev.Dockerfile | 47 +++++++++++++++++++ .../src/Flight.Api/appsettings.docker.json | 4 +- src/Services/Identity/Dockerfile | 9 ++-- src/Services/Identity/dev.Dockerfile | 45 ++++++++++++++++++ .../src/Identity.Api/appsettings.docker.json | 2 +- src/Services/Passenger/Dockerfile | 9 ++-- src/Services/Passenger/dev.Dockerfile | 46 ++++++++++++++++++ .../src/Passenger.Api/appsettings.docker.json | 4 +- .../src/Passenger.Api/appsettings.json | 5 +- 19 files changed, 289 insertions(+), 50 deletions(-) create mode 100644 src/ApiGateway/dev.Dockerfile create mode 100644 src/Services/Booking/dev.Dockerfile create mode 100644 src/Services/Flight/dev.Dockerfile create mode 100644 src/Services/Identity/dev.Dockerfile create mode 100644 src/Services/Passenger/dev.Dockerfile diff --git a/deployments/docker-compose/docker-compose.yaml b/deployments/docker-compose/docker-compose.yaml index f060a17..cc3d7bf 100644 --- a/deployments/docker-compose/docker-compose.yaml +++ b/deployments/docker-compose/docker-compose.yaml @@ -133,7 +133,7 @@ services: args: Version: "1" context: ../../ - dockerfile: src/ApiGateway/Dockerfile + dockerfile: src/ApiGateway/dev.Dockerfile container_name: gateway ports: - "5001:80" @@ -160,7 +160,7 @@ services: args: Version: "1" context: ../../ - dockerfile: src/Services/Flight/Dockerfile + dockerfile: src/Services/Flight/dev.Dockerfile container_name: flight ports: - 5004:80 @@ -186,7 +186,7 @@ services: args: Version: "1" context: ../../ - dockerfile: src/Services/Identity/Dockerfile + dockerfile: src/Services/Identity/dev.Dockerfile container_name: identity ports: - 6005:80 @@ -213,7 +213,7 @@ services: args: Version: "1" context: ../../ - dockerfile: src/Services/Passenger/Dockerfile + dockerfile: src/Services/Passenger/dev.Dockerfile container_name: passenger ports: - 6012:80 @@ -240,7 +240,7 @@ services: args: Version: "1" context: ../../ - dockerfile: src/Services/Booking/Dockerfile + dockerfile: src/Services/Booking/dev.Dockerfile container_name: booking ports: - 6010:80 diff --git a/src/ApiGateway/Dockerfile b/src/ApiGateway/Dockerfile index a31e806..c2b1d62 100644 --- a/src/ApiGateway/Dockerfile +++ b/src/ApiGateway/Dockerfile @@ -8,8 +8,7 @@ COPY ./src/ApiGateway/src/ApiGateway.csproj ./ApiGateway/src/ # Restore nuget packages -RUN --mount=type=cache,id=gateway_nuget,target=/root/.nuget/packages \ - dotnet restore ./ApiGateway/src/ApiGateway.csproj +RUN dotnet restore ./ApiGateway/src/ApiGateway.csproj # Copy project files COPY ./src/BuildingBlocks ./BuildingBlocks/ @@ -19,15 +18,13 @@ COPY ./src/ApiGateway/src ./ApiGateway/src/ # 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 ./ApiGateway/src/ApiGateway.csproj +RUN dotnet build -c Release --no-restore ./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 +RUN dotnet publish -c Release --no-build -o out FROM mcr.microsoft.com/dotnet/aspnet:7.0 diff --git a/src/ApiGateway/dev.Dockerfile b/src/ApiGateway/dev.Dockerfile new file mode 100644 index 0000000..a31e806 --- /dev/null +++ b/src/ApiGateway/dev.Dockerfile @@ -0,0 +1,45 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder +WORKDIR /src + +# Setup working directory for the project +WORKDIR /src +COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./BuildingBlocks/ +COPY ./src/ApiGateway/src/ApiGateway.csproj ./ApiGateway/src/ + + +# Restore nuget packages +RUN --mount=type=cache,id=gateway_nuget,target=/root/.nuget/packages \ + dotnet restore ./ApiGateway/src/ApiGateway.csproj + +# Copy project files +COPY ./src/BuildingBlocks ./BuildingBlocks/ +COPY ./src/ApiGateway/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 ./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:7.0 + +# Setup working directory for the project +WORKDIR /app +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"] + diff --git a/src/ApiGateway/src/appsettings.docker.json b/src/ApiGateway/src/appsettings.docker.json index fa64969..c603cea 100644 --- a/src/ApiGateway/src/appsettings.docker.json +++ b/src/ApiGateway/src/appsettings.docker.json @@ -1,27 +1,46 @@ { + "LogOptions": { + "Level": "Information", + "LogTemplate": "{Timestamp:HH:mm:ss} [{Level:u4}] {Message:lj}{NewLine}{Exception}", + "ElasticUri": "elasticsearch:9200" + }, "Yarp": { "clusters": { "flight": { "destinations": { "destination1": { - "address": "http://flight" + "address": "http://flight:80" + } + } + }, + "identity": { + "destinations": { + "destination1": { + "address": "http://identity:80" } } }, "passenger": { "destinations": { "destination1": { - "address": "http://passenger" + "address": "http://passenger:80" } } }, "booking": { "destinations": { "destination1": { - "address": "http://booking" + "address": "http://booking:80" } } } } + }, + "Jwt": { + "Jwt": { + "Authority": "http://identity:80", + "RequireHttpsMetadata": false, + "MetadataAddress": "http://identity:80/.well-known/openid-configuration" + } } } diff --git a/src/ApiGateway/src/appsettings.json b/src/ApiGateway/src/appsettings.json index 87d776e..713022d 100644 --- a/src/ApiGateway/src/appsettings.json +++ b/src/ApiGateway/src/appsettings.json @@ -69,7 +69,11 @@ } }, "Jwt": { - "Authority": "https://localhost:5005" + "Jwt": { + "Authority": "http://localhost:6005", + "RequireHttpsMetadata": false, + "MetadataAddress": "http://localhost:6005/.well-known/openid-configuration" + } }, "AllowedHosts": "*" } diff --git a/src/Services/Booking/Dockerfile b/src/Services/Booking/Dockerfile index a75037f..1d61dcc 100644 --- a/src/Services/Booking/Dockerfile +++ b/src/Services/Booking/Dockerfile @@ -8,8 +8,7 @@ COPY ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./Services/Bookin # Restore nuget packages -RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages \ - dotnet restore ./Services/Booking/src/Booking.Api/Booking.Api.csproj +RUN dotnet restore ./Services/Booking/src/Booking.Api/Booking.Api.csproj # Copy project files COPY ./src/BuildingBlocks ./BuildingBlocks/ @@ -20,15 +19,13 @@ COPY ./src/Services/Booking/src/Booking.Api/ ./Services/Booking/src/Booking.Api # 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 ./Services/Booking/src/Booking.Api/Booking.Api.csproj +RUN dotnet build -c Release --no-restore ./Services/Booking/src/Booking.Api/Booking.Api.csproj WORKDIR /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 +RUN dotnet publish -c Release --no-build -o out FROM mcr.microsoft.com/dotnet/aspnet:7.0 diff --git a/src/Services/Booking/dev.Dockerfile b/src/Services/Booking/dev.Dockerfile new file mode 100644 index 0000000..a75037f --- /dev/null +++ b/src/Services/Booking/dev.Dockerfile @@ -0,0 +1,46 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder +WORKDIR / + +# Setup working directory for the project +COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./BuildingBlocks/ +COPY ./src/Services/Booking/src/Booking/Booking.csproj ./Services/Booking/src/Booking/ +COPY ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./Services/Booking/src/Booking.Api/ + + +# Restore nuget packages +RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages \ + dotnet restore ./Services/Booking/src/Booking.Api/Booking.Api.csproj + +# Copy project files +COPY ./src/BuildingBlocks ./BuildingBlocks/ +COPY ./src/Services/Booking/src/Booking/ ./Services/Booking/src/Booking/ +COPY ./src/Services/Booking/src/Booking.Api/ ./Services/Booking/src/Booking.Api/ + +# 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 ./Services/Booking/src/Booking.Api/Booking.Api.csproj + +WORKDIR /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:7.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /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"] + diff --git a/src/Services/Booking/src/Booking.Api/appsettings.docker.json b/src/Services/Booking/src/Booking.Api/appsettings.docker.json index de11dea..07011a2 100644 --- a/src/Services/Booking/src/Booking.Api/appsettings.docker.json +++ b/src/Services/Booking/src/Booking.Api/appsettings.docker.json @@ -26,10 +26,10 @@ "Port": 5672 }, "Jwt": { - "Authority": "http://host.docker.internal:6005", + "Authority": "http://identity:80", "Audience": "booking-api", "RequireHttpsMetadata": false, - "MetadataAddress": "http://host.docker.internal:6005/.well-known/openid-configuration" + "MetadataAddress": "http://identity:80/.well-known/openid-configuration" }, "Grpc": { "FlightAddress": "flight:5003", diff --git a/src/Services/Booking/src/Booking.Api/appsettings.json b/src/Services/Booking/src/Booking.Api/appsettings.json index 5bc91a3..f382d23 100644 --- a/src/Services/Booking/src/Booking.Api/appsettings.json +++ b/src/Services/Booking/src/Booking.Api/appsettings.json @@ -22,9 +22,10 @@ } }, "Jwt": { - "Authority": "https://localhost:5005", + "Authority": "http://localhost:6005", "Audience": "booking-api", - "RequireHttpsMetadata": true + "RequireHttpsMetadata": false, + "MetadataAddress": "http://localhost:6005/.well-known/openid-configuration" }, "RabbitMqOptions": { "HostName": "localhost", diff --git a/src/Services/Flight/Dockerfile b/src/Services/Flight/Dockerfile index c7b76cb..21154ac 100644 --- a/src/Services/Flight/Dockerfile +++ b/src/Services/Flight/Dockerfile @@ -8,8 +8,7 @@ COPY ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./Services/Flight/sr # Restore nuget packages -RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ - dotnet restore ./Services/Flight/src/Flight.Api/Flight.Api.csproj +RUN dotnet restore ./Services/Flight/src/Flight.Api/Flight.Api.csproj # Copy project files COPY ./src/BuildingBlocks ./BuildingBlocks/ @@ -20,15 +19,13 @@ COPY ./src/Services/Flight/src/Flight.Api/ ./Services/Flight/src/Flight.Api/ # 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 ./Services/Flight/src/Flight.Api/Flight.Api.csproj +RUN dotnet build -c Release --no-restore ./Services/Flight/src/Flight.Api/Flight.Api.csproj WORKDIR /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 +RUN dotnet publish -c Release --no-build -o out FROM mcr.microsoft.com/dotnet/aspnet:7.0 diff --git a/src/Services/Flight/dev.Dockerfile b/src/Services/Flight/dev.Dockerfile new file mode 100644 index 0000000..c7b76cb --- /dev/null +++ b/src/Services/Flight/dev.Dockerfile @@ -0,0 +1,47 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder +WORKDIR / + +# Setup working directory for the project +COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./BuildingBlocks/ +COPY ./src/Services/Flight/src/Flight/Flight.csproj ./Services/Flight/src/Flight/ +COPY ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./Services/Flight/src/Flight.Api/ + + +# Restore nuget packages +RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ + dotnet restore ./Services/Flight/src/Flight.Api/Flight.Api.csproj + +# Copy project files +COPY ./src/BuildingBlocks ./BuildingBlocks/ +COPY ./src/Services/Flight/src/Flight/ ./Services/Flight/src/Flight/ +COPY ./src/Services/Flight/src/Flight.Api/ ./Services/Flight/src/Flight.Api/ + +# 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 ./Services/Flight/src/Flight.Api/Flight.Api.csproj + +WORKDIR /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:7.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /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"] + diff --git a/src/Services/Flight/src/Flight.Api/appsettings.docker.json b/src/Services/Flight/src/Flight.Api/appsettings.docker.json index 21753c8..5f211e8 100644 --- a/src/Services/Flight/src/Flight.Api/appsettings.docker.json +++ b/src/Services/Flight/src/Flight.Api/appsettings.docker.json @@ -23,10 +23,10 @@ "ConnectionString": "Server=postgres;Port=5432;Database=flight;User Id=postgres;Password=postgres;Include Error Detail=true" }, "Jwt": { - "Authority": "http://host.docker.internal:6005", + "Authority": "http://identity:80", "Audience": "flight-api", "RequireHttpsMetadata": false, - "MetadataAddress": "http://host.docker.internal:6005/.well-known/openid-configuration" + "MetadataAddress": "http://identity:80/.well-known/openid-configuration" }, "RabbitMqOptions": { "HostName": "rabbitmq", diff --git a/src/Services/Identity/Dockerfile b/src/Services/Identity/Dockerfile index e7072b3..9a6c0c6 100644 --- a/src/Services/Identity/Dockerfile +++ b/src/Services/Identity/Dockerfile @@ -7,8 +7,7 @@ COPY ./src/Services/Identity/src/Identity/Identity.csproj ./Services/Identity/sr COPY ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./Services/Identity/src/Identity.Api/ # Restore nuget packages -RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ - dotnet restore ./Services/Identity/src/Identity.Api/Identity.Api.csproj +RUN dotnet restore ./Services/Identity/src/Identity.Api/Identity.Api.csproj # Copy project files COPY ./src/BuildingBlocks ./BuildingBlocks/ @@ -19,15 +18,13 @@ COPY ./src/Services/Identity/src/Identity.Api/ ./Services/Identity/src/Identity # 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 ./Services/Identity/src/Identity.Api/Identity.Api.csproj +RUN dotnet build -c Release --no-restore ./Services/Identity/src/Identity.Api/Identity.Api.csproj WORKDIR /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 +RUN dotnet publish -c Release --no-build -o out FROM mcr.microsoft.com/dotnet/aspnet:7.0 diff --git a/src/Services/Identity/dev.Dockerfile b/src/Services/Identity/dev.Dockerfile new file mode 100644 index 0000000..e7072b3 --- /dev/null +++ b/src/Services/Identity/dev.Dockerfile @@ -0,0 +1,45 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder + +# Setup working directory for the project +WORKDIR / +COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./BuildingBlocks/ +COPY ./src/Services/Identity/src/Identity/Identity.csproj ./Services/Identity/src/Identity/ +COPY ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./Services/Identity/src/Identity.Api/ + +# Restore nuget packages +RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ + dotnet restore ./Services/Identity/src/Identity.Api/Identity.Api.csproj + +# Copy project files +COPY ./src/BuildingBlocks ./BuildingBlocks/ +COPY ./src/Services/Identity/src/Identity/ ./Services/Identity/src/Identity/ +COPY ./src/Services/Identity/src/Identity.Api/ ./Services/Identity/src/Identity.Api/ + +# 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 ./Services/Identity/src/Identity.Api/Identity.Api.csproj + +WORKDIR /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:7.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /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"] + diff --git a/src/Services/Identity/src/Identity.Api/appsettings.docker.json b/src/Services/Identity/src/Identity.Api/appsettings.docker.json index a7e85ff..d040ecb 100644 --- a/src/Services/Identity/src/Identity.Api/appsettings.docker.json +++ b/src/Services/Identity/src/Identity.Api/appsettings.docker.json @@ -9,7 +9,7 @@ "ConnectionString": "Server=postgres;Port=5432;Database=persist_message;User Id=postgres;Password=postgres;Include Error Detail=true" }, "AuthOptions": { - "IssuerUri": "http://host.docker.internal:6005" + "IssuerUri": "http://identity:80" }, "RabbitMqOptions": { "HostName": "rabbitmq", diff --git a/src/Services/Passenger/Dockerfile b/src/Services/Passenger/Dockerfile index f8809ac..a95093c 100644 --- a/src/Services/Passenger/Dockerfile +++ b/src/Services/Passenger/Dockerfile @@ -8,8 +8,7 @@ COPY ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./Services/ # Restore nuget packages -RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ - dotnet restore ./Services/Passenger/src/Passenger.Api/Passenger.Api.csproj +RUN dotnet restore ./Services/Passenger/src/Passenger.Api/Passenger.Api.csproj # Copy project files COPY ./src/BuildingBlocks ./BuildingBlocks/ @@ -20,15 +19,13 @@ COPY ./src/Services/Passenger/src/Passenger.Api/ ./Services/Passenger/src/Passe # 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 ./Services/Passenger/src/Passenger.Api/Passenger.Api.csproj +RUN dotnet build -c Release --no-restore ./Services/Passenger/src/Passenger.Api/Passenger.Api.csproj WORKDIR /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 +RUN dotnet publish -c Release --no-build -o out FROM mcr.microsoft.com/dotnet/aspnet:7.0 diff --git a/src/Services/Passenger/dev.Dockerfile b/src/Services/Passenger/dev.Dockerfile new file mode 100644 index 0000000..f8809ac --- /dev/null +++ b/src/Services/Passenger/dev.Dockerfile @@ -0,0 +1,46 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder +WORKDIR / + +# Setup working directory for the project +COPY ./src/BuildingBlocks/BuildingBlocks.csproj ./BuildingBlocks/ +COPY ./src/Services/Passenger/src/Passenger/Passenger.csproj ./Services/Passenger/src/Passenger/ +COPY ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./Services/Passenger/src/Passenger.Api/ + + +# Restore nuget packages +RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ + dotnet restore ./Services/Passenger/src/Passenger.Api/Passenger.Api.csproj + +# Copy project files +COPY ./src/BuildingBlocks ./BuildingBlocks/ +COPY ./src/Services/Passenger/src/Passenger/ ./Services/Passenger/src/Passenger/ +COPY ./src/Services/Passenger/src/Passenger.Api/ ./Services/Passenger/src/Passenger.Api/ + +# 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 ./Services/Passenger/src/Passenger.Api/Passenger.Api.csproj + +WORKDIR /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:7.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /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"] + diff --git a/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json b/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json index 1f31fea..f55e0f8 100644 --- a/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json +++ b/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json @@ -9,10 +9,10 @@ "ConnectionString": "Server=postgres;Port=5432;Database=persist_message;User Id=postgres;Password=postgres;Include Error Detail=true" }, "Jwt": { - "Authority": "http://host.docker.internal:6005", + "Authority": "http://identity:80", "Audience": "passenger-api", "RequireHttpsMetadata": false, - "MetadataAddress": "http://host.docker.internal:6005/.well-known/openid-configuration" + "MetadataAddress": "http://identity:80/.well-known/openid-configuration" }, "MongoOptions": { "ConnectionString": "mongodb://mongo:27017", diff --git a/src/Services/Passenger/src/Passenger.Api/appsettings.json b/src/Services/Passenger/src/Passenger.Api/appsettings.json index 01ed508..1ec2f4f 100644 --- a/src/Services/Passenger/src/Passenger.Api/appsettings.json +++ b/src/Services/Passenger/src/Passenger.Api/appsettings.json @@ -10,9 +10,10 @@ "DatabaseName": "passenger-db" }, "Jwt": { - "Authority": "https://localhost:5005", + "Authority": "http://localhost:6005", "Audience": "passenger-api", - "RequireHttpsMetadata": "true" + "RequireHttpsMetadata": false, + "MetadataAddress": "http://localhost:6005/.well-known/openid-configuration" }, "RabbitMqOptions": { "HostName": "localhost",