我有一个具有以下结构的 AngularJS 应用程序:
app/
----- controllers/
---------- mainController.js
---------- otherController.js
----- directives/
---------- mainDirective.js
---------- otherDirective.js
----- services/
---------- userService.js
---------- itemService.js
----- js/
---------- bootstrap.js
---------- jquery.js
----- app.js
views/
----- mainView.html
----- otherView.html
----- index.html
我该如何创建自己的镜像并在容器上运行它?我尝试使用 Dockerfile 运行它,但没有成功,而且我对 Docker 还比较陌生,所以如果这很简单,我深表歉意。我只想在 http 服务器上运行它(也许使用 nginx?)
我已经尝试过这些寻求帮助,但没有成功:
- https://www.quora.com/Can-I-have-an-Angular-app-on-Docker-container https://www.quora.com/Can-I-have-an-Angular-app-on-Docker-container
- Docker 中的 AngularJS 和 NodeJS 应用程序 https://stackoverflow.com/questions/34774051/angularjs-and-nodejs-app-in-docker
- Docker 化您的 Angular NodeJS 应用程序 https://stackoverflow.com/questions/34792040/dockerize-your-angular-nodejs-application
首先,按照这个最佳实践指南 https://scotch.io/tutorials/angularjs-best-practices-directory-structure#a-better-structure-and-foundation构建您的角度应用程序结构。 index.html 应放置在根文件夹中。如果不存在,我不确定以下步骤是否有效。
要使用 nginx,您可以按照这个小教程进行操作:使用 nginx 的 Dockerized Angular 应用程序 http://queirozf.com/entries/angular-2-app-running-on-nginx-on-docker-a-simple-example
1.在应用程序的根文件夹中创建一个Dockerfile(在index.html旁边)
FROM nginx
COPY ./ /usr/share/nginx/html
EXPOSE 80
2.Run docker build -t my-angular-app .
在 Dockerfile 的文件夹中。
3.docker run -p 80:80 -d my-angular-app
然后您就可以访问您的应用程序http://localhost http://localhost
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)