diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3729ff0c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj index 48d090ba..f4e3a157 100644 --- a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj +++ b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj @@ -5,6 +5,7 @@ zh-Hans false b93911e3-96d4-453b-aa87-357c154804c2 + Linux @@ -62,6 +63,7 @@ + diff --git a/CoreCms.Net.Web.Admin/Dockerfile b/CoreCms.Net.Web.Admin/Dockerfile index 4dcee072..19cd97f2 100644 --- a/CoreCms.Net.Web.Admin/Dockerfile +++ b/CoreCms.Net.Web.Admin/Dockerfile @@ -1,13 +1,18 @@ -FROM mcr.microsoft.com/dotnet/aspnet:5.0 +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. -RUN apt-get update && apt-get install -y libgdiplus +# 添加基础镜像 +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +#容器中系统的工作空间 WORKDIR /app +#设置Docker容器对外暴露的端口 EXPOSE 80 -COPY ./ /app - -ENV TZ=Asia/Shanghai +#拷贝当前文件夹下的文件到容器中系统的工作空间 +COPY . /app +#容器中使用 ["dotnet","系统启动的dll"] 来运行应用程序 +#使用ENTRYPOINT ["dotnet","系统启动的dll"] +#或使用 CMD ["dotnet","系统启动的dll"] ENTRYPOINT ["dotnet", "CoreCms.Net.Web.Admin.dll"] \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/Dockerfile.original b/CoreCms.Net.Web.Admin/Dockerfile.original new file mode 100644 index 00000000..4dcee072 --- /dev/null +++ b/CoreCms.Net.Web.Admin/Dockerfile.original @@ -0,0 +1,13 @@ +FROM mcr.microsoft.com/dotnet/aspnet:5.0 + +RUN apt-get update && apt-get install -y libgdiplus + +WORKDIR /app + +EXPOSE 80 + +COPY ./ /app + +ENV TZ=Asia/Shanghai + +ENTRYPOINT ["dotnet", "CoreCms.Net.Web.Admin.dll"] \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/Properties/launchSettings.json b/CoreCms.Net.Web.Admin/Properties/launchSettings.json index 1e1e1535..cef85edf 100644 --- a/CoreCms.Net.Web.Admin/Properties/launchSettings.json +++ b/CoreCms.Net.Web.Admin/Properties/launchSettings.json @@ -1,12 +1,4 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:1987", - "sslPort": 0 - } - }, "profiles": { "IIS Express": { "commandName": "IISExpress", @@ -22,6 +14,20 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "http://localhost:5000" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:1987", + "sslPort": 0 } } } \ No newline at end of file diff --git a/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj b/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj index c47bac25..765293f1 100644 --- a/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj +++ b/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj @@ -5,6 +5,7 @@ zh-Hans false 077906fd-e490-4431-9bae-c3a48ae21992 + Linux @@ -66,6 +67,7 @@ + diff --git a/CoreCms.Net.Web.WebApi/Dockerfile b/CoreCms.Net.Web.WebApi/Dockerfile index f8bafdc2..cd9507cd 100644 --- a/CoreCms.Net.Web.WebApi/Dockerfile +++ b/CoreCms.Net.Web.WebApi/Dockerfile @@ -1,14 +1,18 @@ -FROM mcr.microsoft.com/dotnet/aspnet:5.0 +#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/aspnet:7.0 AS base + +#容器中系统的工作空间 WORKDIR /app +#设置Docker容器对外暴露的端口 EXPOSE 80 -COPY ./ /app +#拷贝当前文件夹下的文件到容器中系统的工作空间 +COPY . /app -ENV TZ=Asia/Shanghai - -RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /etc/ssl/openssl.cnf -RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /usr/lib/ssl/openssl.cnf - -ENTRYPOINT ["dotnet", "CoreCms.Net.Web.WebApi.dll"] \ No newline at end of file +#容器中使用 ["dotnet","系统启动的dll"] 来运行应用程序 +#使用ENTRYPOINT ["dotnet","系统启动的dll"] +#或使用 CMD ["dotnet","系统启动的dll"] +ENTRYPOINT ["dotnet", "CoreCms.Net.Web.WebApi.dll"] diff --git a/CoreCms.Net.Web.WebApi/Dockerfile.original b/CoreCms.Net.Web.WebApi/Dockerfile.original new file mode 100644 index 00000000..f8bafdc2 --- /dev/null +++ b/CoreCms.Net.Web.WebApi/Dockerfile.original @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/dotnet/aspnet:5.0 + +WORKDIR /app + +EXPOSE 80 + +COPY ./ /app + +ENV TZ=Asia/Shanghai + +RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /etc/ssl/openssl.cnf +RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /usr/lib/ssl/openssl.cnf + +ENTRYPOINT ["dotnet", "CoreCms.Net.Web.WebApi.dll"] \ No newline at end of file diff --git a/CoreCms.Net.Web.WebApi/Properties/launchSettings.json b/CoreCms.Net.Web.WebApi/Properties/launchSettings.json index 2a00f554..af3efd0d 100644 --- a/CoreCms.Net.Web.WebApi/Properties/launchSettings.json +++ b/CoreCms.Net.Web.WebApi/Properties/launchSettings.json @@ -1,13 +1,4 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:2015", - "sslPort": 0 - } - }, - "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "IIS Express": { "commandName": "IISExpress", @@ -23,6 +14,21 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "http://localhost:5000" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:2015", + "sslPort": 0 } } } \ No newline at end of file