This commit is contained in:
LORENZO\pacio 2025-01-30 11:07:24 +01:00
parent fa103394ee
commit 946b6cf6b5
2 changed files with 35 additions and 21 deletions

View File

@ -1,27 +1,41 @@
# Use the .NET 8 runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
#PER CONNESSIONE A DATABASE MSSQL OBSOLETI
# Install OpenSSL and modify its configuration to allow weaker ciphers and TLSv1
RUN apt-get update && apt-get install -y libssl3 \
&& echo "[system_default_sect]" >> /etc/ssl/openssl.cnf \
&& echo "MinProtocol = TLSv1" >> /etc/ssl/openssl.cnf \
&& echo "CipherString = DEFAULT@SECLEVEL=1" >> /etc/ssl/openssl.cnf \
&& echo "SSL_CTX_set_options(ctx, SSL_OP_NO_TLSv1_3);" >> /etc/ssl/openssl.cnf \
&& rm -rf /var/lib/apt/lists/*
# Build the application
# Use the .NET SDK image for building the application
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["ApiAdHoc_Odoo.csproj", "./"]
RUN dotnet restore "ApiAdHoc_Odoo.csproj"
COPY . .
# Copy the project files and restore dependencies
COPY ApiAdHoc_Odoo.csproj ./
RUN dotnet restore
# Copy the rest of the source code and build the application
COPY . ./
RUN dotnet publish -c Release -o /app
FROM base AS final
# Use the ASP.NET runtime image for the final container
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
# Copy the built application from the build stage
COPY --from=build /app .
# Install dependencies for ODBC driver
RUN apt-get update && \
apt-get install -y curl gnupg2 && \
mkdir -p /usr/share/keyrings && \
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/debian/12/prod bookworm main" > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql18
# Lower OpenSSL security level to allow legacy TLS protocols (TLS 1.0/1.1)
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /usr/lib/ssl/openssl.cnf
# Set environment variables to enable legacy TLS protocols
ENV DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
# Expose the port your API will run on
EXPOSE 80
# Set the entry point for the application
ENTRYPOINT ["dotnet", "ApiAdHoc_Odoo.dll"]

View File

@ -5,7 +5,7 @@ services:
dockerfile: Dockerfile
ports:
- "50000:8080" # HTTP
- "50001:443" # HTTPS
# - "50001:443" # HTTPS
environment:
ASPNETCORE_ENVIRONMENT: "Production"
volumes: