您好研究员程序员,角2应用在AWS泊坞窗容器中运行部署
对于一个项目,我们创建了一个角2,这将是我们的GUI。 此GUI将从Amazon Web Services(AWS)托管的后端API获取他的数据。
图形用户界面也应该在AWS上运行,我们希望将它作为EC2上的Docker容器运行。
图形用户界面在我的电脑上正常工作,但我无法制作出一个Prober Docker容器,它既不能在我的电脑上工作,也不能在AWS上工作。
你们是否知道一个很好的Tutorial/Hello World项目,我可以学习如何在Docker中创建一个Angular 2应用程序?
一些更多的信息Im如何试图做到这一点:
我Dockerfile
# Create image based off of the official Node 6 image
FROM node:6
# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app
# Change directory so that our commands run inside this new dir
WORKDIR /usr/src/app
# Copy dependency definitions
COPY package.json /usr/src/app
# Install dependecies
RUN npm install
# Get all the code needed to run the app
COPY . /usr/src/app
# Expose the port the app runs in
EXPOSE 4200
# Serve the app
CMD ["npm", "start"]
变化package.json
{
...
"scripts": {
"start": "ng serve -H 0.0.0.0",
...
},
...
}
运行docker build -t gui:test .
运行docker run --name gui -p 4200:4200 gui:test
如果我做得正确localhost:4200
应该显示我运行的Angluar 2应用程序,他没有。
编辑: 从妖给出的端口不工作的IP藏汉192.168.99.100:4200
我会为docker image'' build --production'提供一个生成运行,并使用像nginx或apache这样的web服务器来执行此操作。这可以防止在码头图像中提供整个打印稿代码 – Bernhard
为什么不使用s3? – taskiner
@Bernhard所以我得到我的'dist'目录并将它复制到nginx'nginx/html /'并构建一个nginx的docker容器,对不对? – sHamann