ASP.NET 5:使用多项目解决方案构建Docker [英] ASP.NET 5: docker build with multi-projects solution
问题描述
我正在尝试创建一个由4个项目组成的ASP.NET 5解决方案的图像。这是结构:
I'm trying to create an image of my ASP.NET 5 solution which is composed of 4 projects. Here is the structure:
- FlashTools(ASP.NET 5类库)
- 模型(ASP .NET 5类库)
- QuizzCorrector(ASP.NET 5 Web应用程序)
- QuizzService(ASP.NET 5类库)
- FlashTools (ASP.NET 5 class library)
- Models (ASP.NET 5 class library)
- QuizzCorrector (ASP.NET 5 Web Application)
- QuizzService (ASP.NET 5 class library)
我有一个简单的Dockerfile,如下所示:
I've a simple Dockerfile which looks like this:
FROM microsoft/aspnet
COPY . /app
WORKDIR /app
RUN ["kpm", "restore"]
EXPOSE 5004
ENTRYPOINT ["k", "kestrel"]
但不知道该放在哪里。在我的解决方案的根文件夹中,global.json是在我的project.json的Web应用程序文件夹中?
当然我根据这个文件的位置进行了修改。
But not sure where to put it. In the root folder of my solution where a global.json is or in my Web Application folder where my project.json is? Of course I've modified it depending of where this file were located.
无论如何,两者似乎都有效,因为当我运行时下载所有需要的库命令
Anyway both seems to work because it download all the libraries I need when I run the command
docker build -t quizzcorrector。
docker build -t quizzcorrector .
我的问题是暂时停靠码头告诉我
My problem is at a moment docker tells me
无法找到Models> = 1.0.0
Unable to locate Models >= 1.0.0
无法找到FlashTools> = 1.0.0
Unable to locate FlashTools >= 1.0.0
无法找到QuizzService> = 1.0.0
Unable to locate QuizzService >= 1.0.0
我在此线程中看到过 https:// github .com / aspnet / aspnet-docker / issues / 19 在多项目解决方案中,我们应该运行命令kpm pack将我的应用程序打包成可部署和可运行的形式。
I've seen on this thread https://github.com/aspnet/aspnet-docker/issues/19 that in a multi-projects solution we should run the command "kpm pack" to pack my app into a deployable and runnable form.
我找不到使用kpm pack命令的Dockerfiles的任何示例,只有文档: https://github.com/aspnet/Home/wiki/Package-Manager
I could not find any examples of Dockerfiles with the kpm pack command, only the documentation: https://github.com/aspnet/Home/wiki/Package-Manager
我也试过在Dockerfile中使用 ADD 或 COPY 命令将我的项目内容复制到容器的文件系统中,但仍然是同样的错误。
I've also tried of course to use ADD or COPY commands in my Dockerfile to copy the contents of my projects into the filesystem of the container, but still the same error.
感谢帮助我
推荐答案
可能迟到了,但我要回答这个对于那些仍然试图让它工作的人的问题。您需要在解决方案级别上创建一个Docker文件。然后,您需要更新您的工作文件夹以使用Web项目所在的文件夹。以下是最终的Docker文件,考虑到 kpm
和 k
功能被替换为一个 dotnet
工具。
It might be late, but I'm going to answer this question for those who are still trying to get it working. You need to create a Dockerfile on solution level. Then you need to update your working folder to use the one where you web project is located. Here is below the final Dockerfile taking in account that kpm
and k
utilites were replaced with one dotnet
tool.
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app/src/QuizzCorrector
RUN ["dotnet", "restore"]
EXPOSE 5004
ENTRYPOINT ["dotnet", "run"]
这篇关于ASP.NET 5:使用多项目解决方案构建Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!