I am trying to deploy a Meteor application to my Ubuntu 14.04 (Trusty Tahr) VPS. I am using a private Docker registry on DockerHub, with an automated build setup pulling from my Git repository on Bitbucket. That works really well.
However, when I run my container I am not able to see the Meteor app running. I have read about phusion-passenger and Meteor in their documentation, but I think the guide is missing something, as I cannot get it to work.
My approach has been to use meteor to create an application:
meteor create simple-wishes
This creates a directory with a CSS, HTML and JavaScript file inside (and a .meteor
folder). Outside this directory I have created a Dockerfile, looking like this:
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
The webapp.conf file referenced in the Dockerfile looks like this:
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;
}
On my VPS I run a container like this:
docker run -d -p 80:80 -p 2200:22 sohape/simplewishes
This pulls the image from DockerHub and starts the container in daemon mode, mapping port 80 and 22 to port 80 and 2200 on the host.
When I make an HTTP request to the server now (http://simple-wishes.com), I get an error from nginx:
502 Bad Gateway
I must be missing some step here, but I cannot figure out what. So I hope someone can point me in the right direction.