Nginx 与Docker和phusion一起部署Meteor应用程序
我正在尝试将Meteor应用程序部署到我的(Trusty Tahr)。我在DockerHub上使用一个私有注册表,并在上从我的存储库中提取一个自动构建设置。这真的很有效 然而,当我运行我的容器时,我无法看到Meteor应用程序正在运行。我在他们的文档中读到了关于phusion passenger和Meteor的内容,但我认为该指南遗漏了一些东西,因为我无法让它发挥作用 我的方法是使用meteor创建应用程序:Nginx 与Docker和phusion一起部署Meteor应用程序,nginx,meteor,passenger,docker,Nginx,Meteor,Passenger,Docker,我正在尝试将Meteor应用程序部署到我的(Trusty Tahr)。我在DockerHub上使用一个私有注册表,并在上从我的存储库中提取一个自动构建设置。这真的很有效 然而,当我运行我的容器时,我无法看到Meteor应用程序正在运行。我在他们的文档中读到了关于phusion passenger和Meteor的内容,但我认为该指南遗漏了一些东西,因为我无法让它发挥作用 我的方法是使用meteor创建应用程序: meteor create simple-wishes 这将创建一个包含CSS、HT
meteor create simple-wishes
这将创建一个包含CSS、HTML和JavaScript文件的目录(以及.meteor
文件夹)。在此目录之外,我创建了一个Dockerfile,如下所示:
FROM phusion/passenger-nodejs:0.9.14
MAINTAINER Søren Pedersen
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# ssh
ADD ssh/id_rsa.pub /tmp/your_key
RUN cat /tmp/your_key >> /root/.ssh/authorized_keys && rm -f /tmp/your_key
# install meteor
RUN curl https://install.meteor.com | /bin/sh
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Enable nginx
RUN rm -f /etc/service/nginx/down
# Setup app
ADD webapp.conf /etc/nginx/sites-enabled/webapp.conf
RUN mkdir /home/app/simple-wishes
ADD simple-wishes /home/app/simple-wishes
server {
listen 80;
server_name simple-wishes.com;
root /home/app/simple-wishes/public;
passenger_enabled on;
passenger_user app;
passenger_sticky_sessions on;
passenger_set_cgi_param MONGO_URL mongodb://localhost:27017/meteor;
passenger_set_cgi_param MONGO_OPLOG_URL mongodb://localhost:27017/local;
passenger_set_cgi_param ROOT_URL http://simple-wishes.com;
# Set these ONLY if your app is a Meteor bundle!
#passenger_app_type node;
#passenger_startup_file main.js;
}
docker run -d -p 80:80 -p 2200:22 sohape/simplewishes
Dockerfile中引用的webapp.conf文件如下所示:
FROM phusion/passenger-nodejs:0.9.14
MAINTAINER Søren Pedersen
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# ssh
ADD ssh/id_rsa.pub /tmp/your_key
RUN cat /tmp/your_key >> /root/.ssh/authorized_keys && rm -f /tmp/your_key
# install meteor
RUN curl https://install.meteor.com | /bin/sh
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Enable nginx
RUN rm -f /etc/service/nginx/down
# Setup app
ADD webapp.conf /etc/nginx/sites-enabled/webapp.conf
RUN mkdir /home/app/simple-wishes
ADD simple-wishes /home/app/simple-wishes
server {
listen 80;
server_name simple-wishes.com;
root /home/app/simple-wishes/public;
passenger_enabled on;
passenger_user app;
passenger_sticky_sessions on;
passenger_set_cgi_param MONGO_URL mongodb://localhost:27017/meteor;
passenger_set_cgi_param MONGO_OPLOG_URL mongodb://localhost:27017/local;
passenger_set_cgi_param ROOT_URL http://simple-wishes.com;
# Set these ONLY if your app is a Meteor bundle!
#passenger_app_type node;
#passenger_startup_file main.js;
}
docker run -d -p 80:80 -p 2200:22 sohape/simplewishes
在我的VPS上,我运行如下容器:
FROM phusion/passenger-nodejs:0.9.14
MAINTAINER Søren Pedersen
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# ssh
ADD ssh/id_rsa.pub /tmp/your_key
RUN cat /tmp/your_key >> /root/.ssh/authorized_keys && rm -f /tmp/your_key
# install meteor
RUN curl https://install.meteor.com | /bin/sh
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Enable nginx
RUN rm -f /etc/service/nginx/down
# Setup app
ADD webapp.conf /etc/nginx/sites-enabled/webapp.conf
RUN mkdir /home/app/simple-wishes
ADD simple-wishes /home/app/simple-wishes
server {
listen 80;
server_name simple-wishes.com;
root /home/app/simple-wishes/public;
passenger_enabled on;
passenger_user app;
passenger_sticky_sessions on;
passenger_set_cgi_param MONGO_URL mongodb://localhost:27017/meteor;
passenger_set_cgi_param MONGO_OPLOG_URL mongodb://localhost:27017/local;
passenger_set_cgi_param ROOT_URL http://simple-wishes.com;
# Set these ONLY if your app is a Meteor bundle!
#passenger_app_type node;
#passenger_startup_file main.js;
}
docker run -d -p 80:80 -p 2200:22 sohape/simplewishes
这将从DockerHub提取映像,并以守护进程模式启动容器,将主机上的端口80和22映射到端口80和2200
当我向服务器now()发出HTTP请求时,我从nginx得到一个错误:
502 Bad Gateway
我肯定错过了一些步骤,但我不知道是什么。所以我希望有人能给我指出正确的方向。Docker容器内部的本地主机与外部的本地主机不同。如果MongoDB位于自己的容器中或使用著名的DNS条目,您可能需要使用
--link
链接容器。当您在不捆绑应用程序的情况下运行Meteor时,Meteor将
启动MongoDB实例,但不要在默认MongoDB端口上启动
检查堆栈溢出问题的答案。您可以尝试使用我的Docker映像,看看它是如何设置的。要快速运行它,请使用以下命令(请确保首先创建Meteor应用程序包):
你可以看到。这是一个很好的观点但在这种情况下,mongo在同一个容器中-meteor应该自动旋转mongo实例。所以我认为localhost是正确的