NETCORE DockerFile

1.DockerFile配置

rm -rf Dockerfile
cat>>Dockerfile<<EOF
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
# RUN apk add --no-cache icu-libs
EXPOSE 80
EXPOSE 443

# build 
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
RUN dotnet nuget add source https://mirrors.yanwentech.com/repository/nuget-group/index.json -n nuget.yanwentech

RUN dotnet nuget disable source nuget.org WORKDIR /src COPY 项目目录/csproj文件 目标目录/ RUN dotnet restore "目标目录/csproj文件" # copy everything else and build app COPY . . WORKDIR "/src/项目名称" RUN dotnet publish -c release -o /app # final stage/image FROM base AS final WORKDIR /app COPY --from=build /app ./ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false ENTRYPOINT ["dotnet", "项目名称.dll"] EOF

 docker tag 镜像名称  仓库地址路径/镜像名称:版本号

 docker push 仓库地址路径/镜像名称:版本号

 2. netCore 运行环境 配置

 

wget https://download.visualstudio.microsoft.com/download/pr/e89c4f00-5cbb-4810-897d-f5300165ee60/027ace0fdcfb834ae0a13469f0b1a4c8/dotnet-sdk-3.1.426-linux-x64.tar.gz

mkdir dotnet

tar -zxf dotnet-sdk-3.1.426-linux-x64.tar.gz -C dotnet

 

 cd /etc/profile.d  

 vim dotnet.sh 

#!/bin/sh
export DOTNET_ROOT=/usr/local/dotnet
export PATH=$PATH:$DOTNET_ROOT

 

posted on 2023-10-20 17:59  林林七  阅读(71)  评论(0编辑  收藏  举报

导航