首页 > 其他分享 >.net Core 系统 架构回忆录----.net6 环境部署

.net Core 系统 架构回忆录----.net6 环境部署

时间:2022-12-24 19:56:38浏览次数:41  
标签:Core 镜像 EXPOSE 镜像文件 build ----. net6 docker authenticationapi

将应用程序发布到文件夹 ,应用右键 - 【发布】- 【发布到文件夹】

 Dockerfile

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

# 获取aspnet6.0 运行时
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
# 指定工作目录
WORKDIR /app
# 将当前目录下所有文件复制到工作目录,注意 . . 中间是有空格的
COPY . .
# 容器对外暴露的端口,这里的 8090 与你监听的端口一致
EXPOSE 80
EXPOSE 443
# 声明程序入口
ENTRYPOINT ["dotnet", "DiabloCore.WebApplication.dll"]

上传至服务器

 创建镜像文件,文件上传后,进行文件所在目录,cd  文件目录 。然后使用以下命令 创建镜像文件  注意后面的 . 不能少

#docker build -t 镜像名称:版本号 .

  docker build -t authenticationapi:1.0 .

 创建并运行容器

 docker run -d --name authenticationapi -p 8011:80 authenticationapi:1.0

 返回结果

 jwt 服务 使用用户名与密码 返回token ----服务正常。

 保存镜像

 docker save -o authenticationapi.tar authenticationapi

 载入镜像

docker load --input authenticationapi.tar

下一步该将代码放到git上然后尝试添加自动化部署

标签:Core,镜像,EXPOSE,镜像文件,build,----.,net6,docker,authenticationapi
From: https://www.cnblogs.com/daboluo/p/17003286.html

相关文章