为ASP.NET Core 2.1 Angular项目配置Dockerfile [英] Configuring Dockerfile for an ASP.NET Core 2.1 Angular Project

查看:63
本文介绍了为ASP.NET Core 2.1 Angular项目配置Dockerfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手,目前正在尝试使用Angular项目创建ASP.NET Core 2.1。我正在Windows的Docker上使用Linux容器,而我的IDE是VS2017社区版。

I'm a complete newbie on Docker and currently trying to create an ASP.NET Core 2.1 with Angular project. I'm using a Linux Container on Docker for Windows and my IDE is VS2017 community edition.

当前,我收到此错误:


[1]确保已安装'npm',并且可以在PATH目录之一中找到它。
当前PATH环境变量为:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin
确保可执行文件位于一个目录中这些目录,或者更新您的PATH。

[1] Ensure that 'npm' is installed and can be found in one of the PATH directories. Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Make sure the executable is in one of those directories, or update your PATH.

我相信我需要在Docker实例中安装Node.js或您所说的任何东西,并且应该通过Dockerfile。请指出我在假设中的错误。以及如何确保无论我使用哪种容器都将安装依赖项?我期望将来的项目将安装在不同的平台上。

I believe I need to install Node.js in my Docker instance or whatever you call that, and it should be through Dockerfile. Please point out my mistakes in my assumption. And how to ensure that the dependencies will be installed regardless on what kind of container I'm using? I'm expecting that my future projects will be installed on different platforms.

推荐答案

在microsoft / dotnet:2.1-aspnetcore-未安装运行时容器映像npm / nodejs。要将其安装在容器中,请更新docker文件

In the microsoft/dotnet:2.1-aspnetcore-runtime container image npm/nodejs is not installed. To install this in the container update the docker file

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base

# Setup NodeJs
RUN apt-get update && \
    apt-get install -y wget && \
    apt-get install -y gnupg2 && \
    wget -qO- https://deb.nodesource.com/setup_6.x | bash - && \
    apt-get install -y build-essential nodejs
# End setup

WORKDIR /app
EXPOSE 80

只有Angular CLI实时重装无法正常工作。

Only Angular CLI live reload is not working.

这篇关于为ASP.NET Core 2.1 Angular项目配置Dockerfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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