#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
ENV COMPlus_PerfMapEnabled=1
ENV COMPlus_EnableEventLog=1

EXPOSE 80
EXPOSE 443
EXPOSE 54088
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 \
	&& apt-get install -y tcpdump\
	&& 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 restore "EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj"
#RUN dotnet build ./EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj
RUN dotnet publish ./EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj -r linux-x64 -c Release -o /app/publish --self-contained
RUN chmod +x /src/entrypoint.sh
CMD ["/src/entrypoint.sh"]