Deploying Synchro using Docker

When we explain to people that Synchro Server is implemented as a Node.js app, we frequently get asked about our support for Docker. Our general answer is that since Synchro Server is itself just a Node.js app (though a pretty sophisticated one), you are free to deploy and manage it the same way you would with any other Node.js app.

We decided to take that one step further and bundle a starter Docker container definition with Sychro Server to make it even easier to deploy using Docker. In most cases, you will be able to use that container definition directly, without modification.

How it works

If you want to gain some familiarity with deploying Node.js apps using Docker in general, a good starting point can be found on the Node.js web site:

How we do it

When you install Synchro Server using the Synchro CLI command synchro init you will notice that we now include a Dockerfile in the installation. The contents of that Dockerfile is shown below.

# Building a Docker image from an installed and configured Synchro
# Server is very easy!
# The first step is to install Synchro Server using the Synchro CLI command 
# "synchro init" (which you have already done if you are reading this).  
# Then simply add/create your Synchro apps, and add any desired 
# configuration to config.json.  You should then be able to run the Synchro
# Server locally using "node app.js" to test your app.
# When you are ready to build your Docker image, simply set the 
# SYNCHRO__PORT and any other desired environment variables below, then
# proceed to do your "docker build".

# Latest Node.js 4.x LTS
FROM node:argon 

# NOTE: Set any Synchro env variables here

# --- You shouldn't need to touch anything below this ---

# Create app directory
RUN mkdir -p /usr/src/app  
WORKDIR /usr/src/app

# Bundle app source
COPY . /usr/src/app

# Expose the SYNCHRO_PORT set above

# Becaue of some issues with orderly shutdown using "npm start" we are 
# using "node app.js"
CMD [ "node", "app.js" ]  

When you have created or otherwise installed your Synchro apps in this installation and tested them, you can package the Synchro Server installation into a Docker image by doing:

docker build -t yourimagename .  

That's it. One command and you have your Synchro solution in a Docker image, ready to launch in a Docker container!

Other Places to use the Container

You can use your Synchro Docker image anywhere that supports Docker. Particularly for Node.js apps, it's worth looking at Joyent and their Triton container solution.