42 lines
1.6 KiB
Docker
42 lines
1.6 KiB
Docker
# 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"]
|