chore: Update Dockerfiles

This commit is contained in:
Pc 2023-02-24 02:07:50 +03:30
parent a142a2e789
commit a70320b705
19 changed files with 289 additions and 50 deletions

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -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"
}
}
}

View File

@ -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": "*"
}

View File

@ -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

View File

@ -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"]

View File

@ -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",

View File

@ -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",

View File

@ -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

View File

@ -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"]

View File

@ -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",

View File

@ -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

View File

@ -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"]

View File

@ -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",

View File

@ -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

View File

@ -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"]

View File

@ -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",

View File

@ -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",