In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
There are two ways for Docker to deploy an Angular project, one is server-side rendering, which is described in the official document, and the other is to use a node image to compile and put it into the web server. Because of the node environment, it is most convenient to use express.
Create server.js
Const express = require ('express'); const app = express (); const config = {root: _ dirname +' / dist', port: process.env.PORT | | 4200}; / / static resource app.use ('/', express.static (config.root)); / / all routes go to index.htmlapp.all ('*', function (req, res) {res.sendfile (config.root +'/ index.html');}) App.listen (config.port, () = > {console.log ("running.") ;})
Create Dockerfile
FROM node:13.3.0-alpine3.10ENV PORT=4200\ NODE_ENV=production# install express and angular/cliRUN npm install express@4.17.1-g\ & & npm install-g @ angular/cli# create the app directory RUN mkdir-p / app# copy the code to the App directory COPY. / appWORKDIR / app# installation depends on building the program. Here, since I need to reverse proxy to the subdirectory, I added the base-href parameter RUN npm install & & ng build-- base-href / manage/-- prodEXPOSE ${PORT} ENTRYPOINT ["node", "/ app/server.js"]
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.