国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

詳解angular應用容器化部署

2019-11-19 13:16:18
字體:
來源:轉載
供稿:網友

Intro

我自己有做一個個人主頁,雖然效果不怎么樣(不懂設計的典型程序猿...),但是記錄了我對于前端框架及工具的一些實踐,

從開始只有一個 angularjs 制作的頁面到后面加入 less 動態寫css, gulp 自動化的將 less 文件編譯成 css 文件以及自動化的壓縮 js 和 css,到后面加入的基于 vue 和 angular 實現,主要維護的是基于 angular 的,目前 angular 的個人主頁已經支持 PWA(Progressive Web Application),前幾天添加了 docker 部署的支持,記錄一篇文章記錄一下。

編寫 dockerfile

完整的 dockerfile 如下:

FROM node# set working directoryWORKDIR /app# install and cache app dependenciesCOPY . /app# install dependencies and build the angular appRUN yarn && yarn run buildFROM nginx:stable-alpine# copy from dist to nginx root dirCOPY --from=builder /app/dist/weihanli /usr/share/nginx/html# expose port 80EXPOSE 80# set author infoLABEL maintainer="WeihanLi"# run nginx in foreground# https://stackoverflow.com/questions/18861300/how-to-run-nginx-within-a-docker-container-without-haltingCMD ["nginx", "-g", "daemon off;"]

整個 dockerfile 可分為兩部分,第一部分是編譯 angular 應用,生成最后要部署的文件。

第二部分則是將生成的部分拷貝到基于 nginx 的環境中,部署到 nginx 中

打包 docker 鏡像

通過 docker build 命令打包 docker 鏡像,詳細命令使用參考 https://docs.docker.com/engine/reference/commandline/build/

docker build -t weihanli/homepage .

啟動容器

docker run

通過 docker run 命令啟動一個容器,部署打包好的鏡像,詳細命令使用參考 https://docs.docker.com/engine/reference/commandline/run/

docker run -p:5200:80 --rm --name homepage-demo weihanli/homepage

docker compose

通過 docker-compose.yml 啟動容器,啟動命令: docker-compose up

更多 compose 信息參考 https://docs.docker.com/compose/compose-file

docker-compose.yml 文件如下:

version: "3"services: web:  image: "weihanli/homepage"  container_name: "weihanli-homepage-demo"  ports:    - "5200:80"

訪問容器中的應用

訪問 http://localhost:5200 ,即可訪問到容器中部署的應用

More

項目源代碼: https://github.com/WeihanLi/weihanli.github.io

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 依安县| 孙吴县| 沂源县| 长宁县| 威海市| 兴国县| 靖安县| 江油市| 德兴市| 台北县| 苗栗市| 平湖市| 天祝| 庆云县| 英吉沙县| 五家渠市| 邵武市| 江华| 来安县| 慈利县| 达尔| 麦盖提县| 施甸县| 长寿区| 威信县| 大足县| 苏尼特右旗| 裕民县| 嘉禾县| 扎兰屯市| 紫云| 五峰| 武平县| 中宁县| 枣阳市| 哈巴河县| 镶黄旗| 辽阳县| 大洼县| 会宁县| 道真|