作者:手机用户2502911283 | 来源:互联网 | 2023-09-02 20:50
Ivearepowithangularandnodejs.Iperformedinjenkins:我有一个有角的和无弦的回购。我在詹金斯执行:#installglob
I've a repo with angular and nodejs. I performed in jenkins:
我有一个有角的和无弦的回购。我在詹金斯执行:
# install globally
npm install -g bower
npm install -g gulp
# install
bower install
npm install
# build dist folder
gulp build
Now I have in my root:
现在我有了根:
Dockerfile.nginx Dockerfile.nodejs README.md bower.json dist gulp.config.js gulpfile.js node_modules package.json server.js src
I'm copying the dist folder inside my nginx container. So I'm hosting the angular. (with a dockerfile)
我正在复制nginx容器中的dist文件夹。所以这是角函数。(dockerfile)
FROM nginx
# copy folder
COPY dist /usr/share/nginx/html/dist
I'm copying: gulp.config.js gulpfile.js node_modules server.js
to my nodejscontainer. (also with a dockerfile)
我复制:gulp.config。js gulpfile。js node_modules服务器。js nodejscontainer。(也dockerfile)
FROM node
# Create app directory
RUN mkdir -p /usr/src/www
WORKDIR /usr/src/www
# copy
COPY node_modules /usr/src/www/
COPY gulpfile.js /usr/src/www/
COPY gulp.config.js /usr/src/www/
COPY server.js /usr/src/www/
EXPOSE 8080
CMD [ "node", "server.js" ]
I run the 2 containers but the nginx does not communicate with the nodejs
我运行了两个容器,但是nginx不与nodejs通信
EDIT1: Start containers:
EDIT1:启动容器:
docker run -d -p 8888:8888 --name "nodejs" localhost:5000/test/nodejs:1
docker run -d -p 80:80 --name "nginx" localhost:5000/test/nginx:1
EDIT2: My nginx.conf looks like this:
EDIT2:我的nginx。设计是这样的:
http {
upstream node-app {
least_conn;
server nodejs:8888 weight=10 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
location /dist {
alias /usr/share/nginx/html/dist/;
}
location ~* /api {
#location / {
proxy_pass http://node-app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
My server.js looks like:
我的服务器。js的样子:
app.get('/api/hello', requestProxy({
url: xxx + "/hello"
}));
2 个解决方案