devops: added dockerfile and other configs

This commit is contained in:
2025-09-01 10:18:52 -06:00
parent c1df5e354b
commit a858e5e5de
5 changed files with 66 additions and 3 deletions

42
Dockerfile Normal file
View File

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