docker build 本文共有4087个字,关键词: docker build -t mbsapi . 打包已发布的系统 #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. #Dockerfile FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 5566 RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo 'Asia/Shanghai' >/etc/timezone ADD ./net6.0/ /app ENTRYPOINT ["dotnet", "Admin.dll","--urls","https://*:5566"] 编译并打包 FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 5566 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["./", "/src"] RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo 'Asia/Shanghai' >/etc/timezone RUN dotnet restore "Admin/Admin.csproj" COPY . . WORKDIR "/src/Admin" RUN dotnet build "Admin.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "Admin.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "Admin.dll","--urls","http://*:5566"] #启动时设定 添加以下参数 -v /etc/timezone:/etc/timezone \ -v /etc/localtime:/etc/localtime .dockerignore **/.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 ----------------------------完----------------------------------- #以下还在研究中。。 FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 5566 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["./", "/src"] RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo 'Asia/Shanghai' >/etc/timezone RUN dotnet restore "Admin/Admin.csproj" COPY . . WORKDIR "/src/Admin" RUN dotnet build "Admin.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "Admin.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . run echo "[Unit]\n\ Description=mbsapi\n\ [Service]\n\ WorkingDirectory=/app\n\ ExecStart=dotnet Admin.dll\n\ Restart=always\n\ RestartSec=10\n\ KillSignal=SIGINT\n\ SyslogIdentifier=mbsapi\n\ User=root\n\ Environment=ASPNETCORE_ENVIRONMENT=Production\n\ Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false\n\ [Install]\n\ WantedBy=multi-user.target">>/usr/lib/systemd/system/mbsapi.service run chomd +x /usr/lib/systemd/system/mbsapi.service run systemctl daemon-reload run systemctl enable mbsapi #systemctl start mbsapi #ENTRYPOINT ["dotnet", "Admin.dll","--urls","http://*:5566"] ENTRYPOINT ["systemctl start mbsapi"] 添加为系统服务 echo "[Unit] >Description=mbsapi >[Service] >WorkingDirectory=/app >ExecStart=dotnet /app/Admin.dll >Restart=always >RestartSec=10 >KillSignal=SIGINT >SyslogIdentifier=mbsapi >User=root >Environment=ASPNETCORE_ENVIRONMENT=Production >>Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false >[Install] >WantedBy=multi-user.target">>/usr/lib/systemd/system/mbsapi.service chomd +x /usr/lib/systemd/system/mbsapi.service #.. install --reinstall systemd systemctl daemon-reload systemctl enable mbsapi systemctl start mbsapi 「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」 赞赏 × 梦白沙 (๑>ڡ<)☆谢谢老板~ 1元 2元 5元 10元 50元 任意金额 2元 使用微信扫描二维码完成支付 版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。 Docker 2022-08-01 评论 404 次浏览