b1f83aa7ab
- Disabilitato target MSBuild GenerateVersionJson durante build CI/CD - Aggiunta condizione: non esegue se ContinuousIntegrationBuild=true - Aggiornato Dockerfile per usare /p:ContinuousIntegrationBuild=true - Previene sovrascrittura del version.json generato dal workflow Gitea - Risolve problema: container mostra v1.0.0-dev invece della versione da git tag
67 lines
1.9 KiB
Docker
67 lines
1.9 KiB
Docker
# Dockerfile per Linux
|
|
# Multi-stage build per ottimizzare le dimensioni dell'immagine finale
|
|
|
|
# Stage 1: Build
|
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
|
WORKDIR /src
|
|
|
|
# Copia i file di progetto e ripristina le dipendenze
|
|
COPY ["Data_Coupler/Data_Coupler.csproj", "Data_Coupler/"]
|
|
COPY ["DataConnection/DataConnection.csproj", "DataConnection/"]
|
|
COPY ["CredentialManager/CredentialManager.csproj", "CredentialManager/"]
|
|
COPY ["Components/Components.csproj", "Components/"]
|
|
COPY ["nuget.config", "./"]
|
|
|
|
# Ripristina le dipendenze per tutti i progetti
|
|
RUN dotnet restore "Data_Coupler/Data_Coupler.csproj"
|
|
|
|
# Copia tutto il codice sorgente
|
|
COPY . .
|
|
|
|
# Build del progetto principale
|
|
WORKDIR "/src/Data_Coupler"
|
|
RUN dotnet build "Data_Coupler.csproj" -c Release -o /app/build /p:ContinuousIntegrationBuild=true
|
|
|
|
# Stage 2: Publish
|
|
FROM build AS publish
|
|
RUN dotnet publish "Data_Coupler.csproj" -c Release -o /app/publish \
|
|
/p:SelfContained=false \
|
|
/p:PublishTrimmed=false \
|
|
/p:PublishSingleFile=false \
|
|
/p:ContinuousIntegrationBuild=true
|
|
|
|
# Stage 3: Runtime
|
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
|
|
WORKDIR /app
|
|
|
|
# Installa le dipendenze necessarie per ExcelDataReader e SQLite
|
|
RUN apt-get update && apt-get install -y \
|
|
libgdiplus \
|
|
libc6-dev \
|
|
sqlite3 \
|
|
libsqlite3-dev \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Crea la directory per il database con i permessi corretti
|
|
RUN mkdir -p /var/lib/Data_Coupler && \
|
|
chmod 777 /var/lib/Data_Coupler
|
|
|
|
# Copia i file pubblicati
|
|
COPY --from=publish /app/publish .
|
|
|
|
# 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 curl --fail http://localhost:7550/health || exit 1
|
|
|
|
# Punto di ingresso
|
|
ENTRYPOINT ["dotnet", "Data_Coupler.dll"]
|