Files
Data-Coupler/Dockerfile.windows
T

56 lines
1.8 KiB
Docker

# Dockerfile per Windows
# Multi-stage build per ottimizzare le dimensioni dell'immagine finale
# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:9.0-nanoserver-ltsc2022 AS build
WORKDIR /s
# Copia i file di progetto e ripristina le dipendenze
COPY ["Data_Coupler/Data_Coupler.csproj", "DC/"]
COPY ["DataConnection/DataConnection.csproj", "DCon/"]
COPY ["CredentialManager/CredentialManager.csproj", "CM/"]
COPY ["Components/Components.csproj", "Comp/"]
COPY ["nuget.config", "./"]
# Ripristina le dipendenze per tutti i progetti con path corti
RUN dotnet restore "DC/Data_Coupler.csproj" --disable-parallel --packages /p
# Copia tutto il codice sorgente con struttura abbreviata
COPY ["Data_Coupler/", "DC/"]
COPY ["DataConnection/", "DCon/"]
COPY ["CredentialManager/", "CM/"]
COPY ["Components/", "Comp/"]
# Build del progetto principale
WORKDIR "/s/DC"
RUN dotnet build "Data_Coupler.csproj" -c Release -o /a/b --no-restore
# Stage 2: Publish
FROM build AS publish
RUN dotnet publish "Data_Coupler.csproj" -c Release -o /a/p --no-restore /p:UseAppHost=false
# Stage 3: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0-nanoserver-ltsc2022 AS final
WORKDIR /app
# Crea la directory per il database
RUN mkdir C:\ProgramData\Data_Coupler
# Copia i file pubblicati
COPY --from=publish /a/p .
# Configura le variabili d'ambiente
ENV ASPNETCORE_URLS=http://+:7550
ENV DOTNET_RUNNING_IN_CONTAINER=true
ENV ASPNETCORE_ENVIRONMENT=Production
# Espone la porta dell'applicazione
EXPOSE 7550
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD powershell -Command "try { $response = Invoke-WebRequest -Uri http://localhost:7550/health -UseBasicParsing -TimeoutSec 5; if ($response.StatusCode -eq 200) { exit 0 } else { exit 1 } } catch { exit 1 }"
# Punto di ingresso
ENTRYPOINT ["dotnet", "Data_Coupler.dll"]