From a858e5e5def2493a0f119e0a5be7079c88ad3d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20White?= Date: Mon, 1 Sep 2025 10:18:52 -0600 Subject: [PATCH] devops: added dockerfile and other configs --- .dockerignore | 12 ++++++ .../Core.Inventory.External.csproj | 4 +- .../Core.Inventory.Service.API.csproj | 2 +- Dockerfile | 42 +++++++++++++++++++ nuget.config | 9 ++++ 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 nuget.config diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4971510 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +**/bin +**/obj +**/out +**/.vs +**/.idea +**/.git +**/.gitignore +**/node_modules +*.user +*.swp +*.swo +.DS_Store diff --git a/Core.Inventory.External/Core.Inventory.External.csproj b/Core.Inventory.External/Core.Inventory.External.csproj index 2c5fc6b..0c98b32 100644 --- a/Core.Inventory.External/Core.Inventory.External.csproj +++ b/Core.Inventory.External/Core.Inventory.External.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Core.Inventory.Service.API/Core.Inventory.Service.API.csproj b/Core.Inventory.Service.API/Core.Inventory.Service.API.csproj index da915c8..dd4849a 100644 --- a/Core.Inventory.Service.API/Core.Inventory.Service.API.csproj +++ b/Core.Inventory.Service.API/Core.Inventory.Service.API.csproj @@ -8,7 +8,7 @@ - + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b93e462 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# ===== Build stage ===== +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src + +# Usaremos la config de NuGet de la raíz (BaGet + nuget.org) +COPY nuget.config ./ + +# Copiamos SOLO los .csproj primero (mejor caché en restore) +COPY Core.Inventory.Service.API/Core.Inventory.Service.API.csproj Core.Inventory.Service.API/ +COPY Core.Inventory.Application/Core.Inventory.Application.csproj Core.Inventory.Application/ +COPY Core.Inventory.External/Core.Inventory.External.csproj Core.Inventory.External/ + +# Restaura con tu nuget.config +RUN dotnet restore Core.Inventory.Service.API/Core.Inventory.Service.API.csproj --configfile ./nuget.config + +# Ahora sí, copia todo el código +COPY . . + +# Publica artefactos (sin apphost para imagen más pequeña) +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish Core.Inventory.Service.API/Core.Inventory.Service.API.csproj \ + -c $BUILD_CONFIGURATION -o /app/out /p:UseAppHost=false + +# ===== Runtime stage ===== +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime +WORKDIR /app + +# Copiamos el publish +COPY --from=build /app/out . + +# Variables típicas (ajústalas luego en compose) +ENV ASPNETCORE_URLS=http://+:8080 \ + ASPNETCORE_ENVIRONMENT=Production + +# Exponemos el puerto HTTP +EXPOSE 8080 + +# Opcional: healthcheck si tienes /health +# HEALTHCHECK --interval=30s --timeout=5s --retries=5 \ +# CMD wget -qO- http://localhost:8080/health || exit 1 + +ENTRYPOINT ["dotnet", "Core.Inventory.Service.API.dll"] diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..c4407da --- /dev/null +++ b/nuget.config @@ -0,0 +1,9 @@ + + + + + + + + +