RUN apt-get update && apt-get install -y \
inotify-tools
#!/bin/sh
# 设置ASPNETCORE_ENVIRONMENT环境变量
if [ -z "$ASPNETCORE_ENVIRONMENT" ]; then
export ASPNETCORE_ENVIRONMENT=Production
fi
# 启动ASP.NET Core应用程序
dotnet /app/MyApp.dll &
# 监测文件更改并重新启动应用程序
while inotifywait -r -e modify,create,delete,move /app; do
pkill -SIGTERM dotnet
dotnet /app/MyApp.dll &
done
COPY start.sh /start.sh
RUN chmod +x /start.sh
ENTRYPOINT ["/start.sh"]
通过这种方式,Docker容器启动时将运行一个shell脚本,该脚本将启动ASP.NET Core应用程序并监视文件更改,以便在文件更改时重新启动应用程序。
上一篇:asp.netcoreangularcookie验证过期cors错误
下一篇:Asp.NetCoreAngularweb应用程序中使用“ValidateAntiForgeryToken”端点属性以抵御CSRF攻击。