#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS final
EXPOSE 80
EXPOSE 443
EXPOSE 2222 

RUN sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf

RUN apt-get update \
    && apt-get install -y --no-install-recommends dialog \
    && apt-get install -y --no-install-recommends openssh-server \
	&& mkdir -p /run/sshd \
    && echo "root:Docker!" | chpasswd 
	
COPY sshd_config /etc/ssh/sshd_config

# Install dotnet debug tools
RUN dotnet tool install --tool-path /tools dotnet-trace \
 && dotnet tool install --tool-path /tools dotnet-counters \
 && dotnet tool install --tool-path /tools dotnet-dump \
 && dotnet tool install --tool-path /tools dotnet-gcdump
 
RUN apt update
RUN apt install -y linux-perf
#RUN echo 0 > /proc/sys/kernel/kptr_restrict
WORKDIR /src
COPY . .
RUN export DOTNET_PerfMapEnabled=1
RUN dotnet build ./EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj
CMD dotnet run --project ./EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj