diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..62d3acc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /source + +# copy csproj and restore as distinct layers +COPY *.sln . +COPY DotnetApiPostgres.Api/*.csproj ./DotnetApiPostgres.Api/ +RUN dotnet restore + +# copy everything else and build app +COPY DotnetApiPostgres.Api/. ./DotnetApiPostgres.Api/ +WORKDIR /source/DotnetApiPostgres.Api +RUN dotnet publish -c release -o /app + +# final stage/image +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final +WORKDIR /app +COPY --from=build /app ./ + +ENTRYPOINT ["dotnet", "DotnetApiPostgres.Api.dll"] diff --git a/DotnetApiPostgres.Api/HttpFiles/create-person.http b/DotnetApiPostgres.Api/HttpFiles/create-person.http index bd79129..4ffd3ff 100644 --- a/DotnetApiPostgres.Api/HttpFiles/create-person.http +++ b/DotnetApiPostgres.Api/HttpFiles/create-person.http @@ -2,5 +2,5 @@ POST https://localhost:7294/api/people/ HTTP/1.1 Content-Type: application/json { - "name": "Jane Doe" + "name": "John Doe" } \ No newline at end of file diff --git a/DotnetApiPostgres.Api/appsettings.Development.json b/DotnetApiPostgres.Api/appsettings.Development.json index 9eb48af..0c208ae 100644 --- a/DotnetApiPostgres.Api/appsettings.Development.json +++ b/DotnetApiPostgres.Api/appsettings.Development.json @@ -4,8 +4,5 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } - }, - "ConnectionStrings": { - "default": "Host=localhost;Port=5432;Database=PersonDb;Username=postgres;Password=Ravindra@123" } } diff --git a/DotnetApiPostgres.Api/appsettings.json b/DotnetApiPostgres.Api/appsettings.json index 10f68b8..9b9e6b8 100644 --- a/DotnetApiPostgres.Api/appsettings.json +++ b/DotnetApiPostgres.Api/appsettings.json @@ -5,5 +5,8 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "default": "Host=192.168.x.x;Port=5432;Database=PersonDb;Username=postgres;Password=Ravindra@123" + } } diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..65086f4 --- /dev/null +++ b/compose.yml @@ -0,0 +1,20 @@ +services: + web_api: + container_name: perons_api_app + build: . + ports: + - 8080:8080 + depends_on: + - "db" + db: + image: postgres + container_name: postgres_db + ports: + - 5432:5432 + environment: + POSTGRES_PASSWORD: Ravindra@123 + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: