У меня есть репо с угловыми и nodejs. я выступал в Дженкинс:Как подключить мой NodeJS с моим угловым (в Nginx)
# install globally
npm install -g bower
npm install -g gulp
# install
bower install
npm install
# build dist folder
gulp build
Теперь у меня в корне:
Dockerfile.nginx Dockerfile.nodejs README.md bower.json dist gulp.config.js gulpfile.js node_modules package.json server.js src
Я копирую папку Dist внутри моего Nginx контейнера. Поэтому у меня есть угловой. (С dockerfile)
FROM nginx
# copy folder
COPY dist /usr/share/nginx/html/dist
Я копирование: gulp.config.js gulpfile.js node_modules server.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" ]
Я запустить 2 контейнера, но Nginx не общается с nodejs
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: Мой nginx.conf выглядит так:
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;
}
}
}
Мой server.js выглядит следующим образом:
app.get('/api/hello', requestProxy({
url: xxx + "/hello"
}));
Вы можете поделиться, как запустить эти 2 контейнера? – Thomasleveil