• Jun 26, 2015
Recently, we had someone on Twitter asking us if we support Meteor. As we were not sure, I thought challenge accepted we could just try it out. And it was easier than I thought. If you’re really in a hurry here’s the 1 minute quick fix:
swarm up
Now keep in mind I’m not a developer per se and have never even looked at Meteor beyond the above-linked website. As I wanted to prove that it works as quickly as possible, I started in what sounds like a reverse order. I started with a Docker image for deploying the application. After some looking around and searching the Docker Hub I found what seems to be by far the most used Docker image for Meteor deployments. It has over 400K downloads, which is quite an accomplishment by itself, and a regularly maintained GitHub repository showing what the team is working on. It is currently based on ubuntu:trusty, but there’s already a branch that tries porting it to the much smaller Alpine Linux.
Some of its notable features (and you can tell me or better even the maintainers of the image if you need more) are
First I wanted to get it running locally using Docker Compose, so we know it really works. That was actually pretty straight forward.
Here is the docker-compose.yml
file:
meteor:
image: ulexus/meteor
ports:
- "80:80"
links:
- mongo
environment:
- REPO=https://github.com/Differential/meteor-boilerplate
- ROOT_URL=http://192.168.59.103
mongo:
image: mongo
ports:
- "27017:27017"
The meteor
component just needs to know the port it exposes, that it’s linked to a MongoDB component called mongo and some additional environment variables first to get some code into the container and second to tell the container where it will be available to the outside. Here I’m currently using my local boot2docker IP as I’m on a Mac. The mongo
component runs a simple MongoDB using the official image from the Docker Hub.
The part where it comes to getting writing some Meteor code to run in that container was actually not trivial for me, because, as I mentioned above, I’ve never worked with Meteor before. Luckily, I found a nice boilerplate Meteor application on GitHub that could be easily pulled into the container by the above-mentioned image.
Now a simple docker-compose up
and the Meteor application is running. Be sure to replace the ROOT_URL
environment variable with the IP of your docker host (mine runs in boot2docker, so it’s http://192.168.59.103
).
Now that we have it running with Docker Compose, it’s a very small step to getting it deployed to production, once you have a Giant Swarm account. You just need to translate your docker-compose.yml
into a swarm.json
. You can use CYtoSJ for that, a little command line tool. However, for such a short file it’s also quite simple to write it yourself:
{
"name": "meteor-test",
"components": {
"meteor-test": {
"image": "ulexus/meteor",
"ports": [
80
],
"env": [
"REPO=https://github.com/Differential/meteor-boilerplate",
"ROOT_URL=http://meteor-puja.gigantic.io"
],
"domains": {
"80/tcp": [
"meteor-puja.gigantic.io"
]
},
"links": [
{
"component": "mongo",
"target_port": "27017/tcp"
}
]
},
"mongo": {
"image": "mongo",
"ports": [
27017
]
}
}
}
The only small thing that changed is that our application now gets a real domain, which we have to define and then also give to Meteor through the environment variable. Everything else is pretty straight forward. A simple swarm up
and it’s deployed and running under your desired domain.
Now, if you want to deploy your own Meteor application in this way, it’s 3 easy steps:
swarm up
Voilá, you have just deployed your Meteor application to production (or testing/staging). If everything goes right, this process shouldn’t take you more than 1 minute. If you think that’s cool, but you don’t have a Giant Swarm account, yet, be sure to request an invite. If you need help with using the image, you can find all details in the according GitHub repo. And if you have anything else you want to tell us, feel free to comment below or contact us directly.
These Stories on Tech
A look into the future of cloud native with Giant Swarm.
A look into the future of cloud native with Giant Swarm.
A Technical Product Owner explores Kubernetes Gateway API from a Giant Swarm perspective.
We empower platform teams to provide internal developer platforms that fuel innovation and fast-paced growth.
GET IN TOUCH
General: hello@giantswarm.io
CERTIFIED SERVICE PROVIDER
No Comments Yet
Let us know what you think