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

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

问题描述

我是 Docker 的完全新手,目前正在尝试使用 Angular 项目创建 ASP.NET Core 2.1.我在 Docker for Windows 上使用 Linux Container,我的 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-runtime 容器镜像中未安装 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天全站免登陆