From f8f29823cc59c38df3e2248ba1de31fb5c4a7859 Mon Sep 17 00:00:00 2001 From: GauravAhuja05 Date: Sat, 17 Jan 2026 18:47:05 +0530 Subject: [PATCH] Updated 17/jan/2026 --- CustomerWebApi/.dockerignore | 30 ++++++++++++++++++++++++++++ CustomerWebApi/CustomerWebApi.csproj | 1 + CustomerWebApi/Dockerfile_bak2 | 28 ++++++++++++++++++++++++++ CustomerWebApi/Program.cs | 12 ++++++++--- 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 CustomerWebApi/.dockerignore create mode 100644 CustomerWebApi/Dockerfile_bak2 diff --git a/CustomerWebApi/.dockerignore b/CustomerWebApi/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/CustomerWebApi/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/CustomerWebApi/CustomerWebApi.csproj b/CustomerWebApi/CustomerWebApi.csproj index 35726a7..fe58e7c 100644 --- a/CustomerWebApi/CustomerWebApi.csproj +++ b/CustomerWebApi/CustomerWebApi.csproj @@ -6,6 +6,7 @@ enable ..\docker-compose.dcproj Linux + . diff --git a/CustomerWebApi/Dockerfile_bak2 b/CustomerWebApi/Dockerfile_bak2 new file mode 100644 index 0000000..802fe83 --- /dev/null +++ b/CustomerWebApi/Dockerfile_bak2 @@ -0,0 +1,28 @@ +# 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. + +# This stage is used when running from VS in fast mode (Default for Debug configuration) +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 + + +# This stage is used to build the service project +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["CustomerWebApi.csproj", "."] +RUN dotnet restore "./CustomerWebApi.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "./CustomerWebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# This stage is used to publish the service project to be copied to the final stage +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./CustomerWebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "CustomerWebApi.dll"] \ No newline at end of file diff --git a/CustomerWebApi/Program.cs b/CustomerWebApi/Program.cs index 7bd47fd..3c0e0e9 100644 --- a/CustomerWebApi/Program.cs +++ b/CustomerWebApi/Program.cs @@ -7,10 +7,16 @@ builder.Services.AddControllers(); +///* Database Context Dependency Injection */ +//var dbHost = Environment.GetEnvironmentVariable("DESKTOP-TGLDFBO\\SQLEXPRESS"); //DB_HOST +//var dbName = Environment.GetEnvironmentVariable("MicroServices");//DB_NAME +//var dbPassword = Environment.GetEnvironmentVariable("123456"); + + /* Database Context Dependency Injection */ -var dbHost = Environment.GetEnvironmentVariable("DB_HOST"); -var dbName = Environment.GetEnvironmentVariable("DB_NAME"); -var dbPassword = Environment.GetEnvironmentVariable("DB_SA_PASSWORD"); +var dbHost = "DESKTOP-TGLDFBO\\SQLEXPRESS"; //DB_HOST +var dbName = "MicroServices";//DB_NAME +var dbPassword = "123456"; var connectionString = $"Data Source={dbHost};Initial Catalog={dbName};User ID=sa;Password={dbPassword}"; builder.Services.AddDbContext(opt => opt.UseSqlServer(connectionString)); /* ===================================== */