diff --git a/ApiAdHoc_Odoo/ApiAdHoc_Odoo.csproj b/ApiAdHoc_Odoo/ApiAdHoc_Odoo.csproj index c8aa732..a3e5701 100644 --- a/ApiAdHoc_Odoo/ApiAdHoc_Odoo.csproj +++ b/ApiAdHoc_Odoo/ApiAdHoc_Odoo.csproj @@ -8,7 +8,7 @@ - + diff --git a/ApiAdHoc_Odoo/Dockerfile b/ApiAdHoc_Odoo/Dockerfile new file mode 100644 index 0000000..12549dd --- /dev/null +++ b/ApiAdHoc_Odoo/Dockerfile @@ -0,0 +1,41 @@ +# Use the .NET SDK image for building the application +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src + +# 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 + +# 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"] diff --git a/ApiAdHoc_Odoo/Program.cs b/ApiAdHoc_Odoo/Program.cs index c5d9a9c..d7830f4 100644 --- a/ApiAdHoc_Odoo/Program.cs +++ b/ApiAdHoc_Odoo/Program.cs @@ -2,9 +2,13 @@ using ApiAdHoc_Odoo.Data; using ApiAdHoc_Odoo.Models; using Microsoft.EntityFrameworkCore; using System; +using System.Net; var builder = WebApplication.CreateBuilder(args); +// Enable legacy TLS protocols (TLS 1.0/1.1) +ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; + // Add services to the container. builder.Services.AddControllers(); diff --git a/ApiAdHoc_Odoo/docker-compose.yml b/ApiAdHoc_Odoo/docker-compose.yml new file mode 100644 index 0000000..ee6822a --- /dev/null +++ b/ApiAdHoc_Odoo/docker-compose.yml @@ -0,0 +1,13 @@ +services: + api-adhoc-odoo: + build: + context: . + dockerfile: Dockerfile + ports: + - "50000:8080" # HTTP +# - "50001:443" # HTTPS + environment: + ASPNETCORE_ENVIRONMENT: "Production" + volumes: + - ./logs:/app/logs # Optional: Log files storage + restart: unless-stopped