asp.net core 2.0-多个项目解决方案docker文件 [英] asp.net core 2.0 - multiple projects solution docker file

查看:259
本文介绍了asp.net core 2.0-多个项目解决方案docker文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[用于Linux的ASP.NET Core 2.0和Docker]

[asp.net core 2.0 and docker for linux]

我对docker完全陌生,在我有2个项目的解决方案的情况下,试图弄清楚如何使用docker.我见过的所有教程都显示一个项目.

I am completely new to docker and trying to figure out how to use docker in a case where i have a solution with 2 projects. All tutorials i've seen show with single project.

因此,如果有人可以逐步展示解决方案,我将非常感激.

So, if someone could show step by step solution i would really appreciate it.

我的解决方案结构如下:

i have a solution structure like:

Solution.sln
|______WebAPIProject.csproj
|______ClassLibraryProject.csproj

在Visual Studio中,我向解决方案添加了docker支持并获得了以下文件:

In Visual studio, i've added docker support to solution and got these files:

在WebAPIProject下,它创建了这个 Docker文件:

Under WebAPIProject, it created this Docker file:

FROM microsoft/aspnetcore:2.0
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "WebAPIProject.dll"]

然后,在单独的docker-compose'project'下,我得到了:

then, under separate docker-compose 'project' i've got:

docker-compose.ci.build.yml

version: '3'

services:
  ci-build:
    image: microsoft/aspnetcore-build:1.0-2.0
    volumes:
      - .:/src
    working_dir: /src
    command: /bin/bash -c "dotnet restore ./Solution.sln && dotnet publish ./Solution.sln -c Release -o ./obj/Docker/publish"

docker.compose.yml 文件

version: '3'

services:
  WebAPIProject:
    image: WebAPIProject
    build:
      context: ./WebAPIProject
      dockerfile: Dockerfile

我确定它在路径上是微不足道的,但是我对它却一无所知,所以如果有人能对它有所了解?

I am sure its something trivial with paths but i am just pretty lost with it all so if someone could shed a bit of a light on it?

推荐答案

虽然我了解dotnet核心并非特定于Windows,并且并不是每个人都将使用Visual Studio,但Microsoft在Visual Studio中已包含了这一简洁功能Studio(于2017年尝试).

While I understand that dotnet core isn't specific to Windows and not everyone is going to be using Visual Studio, there's this neat feature that Microsoft has included inside Visual Studio (Tried it in 2017).

  1. 右键单击Web项目.
  2. 选择添加.
  3. 然后是"Docker支持".这将自动将多个项目提取到容器中.

如果您有多个Web项目,则分别对每个项目重复该步骤.

If you have multiple Web Projects, repeat the step individually for each.

这里是参考:如果在运行Docker容器时碰巧遇到任何问题,请尝试在"Windows功能"中取消选择Hyper-V Services(在开始"菜单中搜索Windows Features),再次选择,然后重新启动计算机. 在此处.

If you happen to run with any issues when running the Docker container, try deselecting Hyper-V Services in "Windows Features" (Search for Windows Features in Start Menu), selecting again, and then restarting your computer. Check here.

这篇关于asp.net core 2.0-多个项目解决方案docker文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆