How to Deploy a Meteor App Using Dokku
Before you begin with the instructions on this page, you might want to read the Dokku Getting Started Guide.
Please ensure you are using Meteor version v220.127.116.11 (released on 12/8/17) or higher, which includes a version of NodeJS patched for a major vulnerability.
Create and Configure Your App
Connect to your machine and define your initial app:
ssh deploy@SERVER-ID.healthcareblocks.com dokku apps:create my-app-name
dokku config:set my-app-name MONGO_URL=mongodb://USER:PASS@HOST:27017/DB_NAME?ssl=true
and the ROOT_URL:
dokku config:set my-app-name ROOT_URL=https://mydomain.com
Configuring the Meteor Buildpack
Register the buildpack:
dokku config:set my-app-name BUILDPACK_URL=https://github.com/AdmitHub/meteor-buildpack-horse.git
This buildpack will be automatically downloaded each time you deploy, ensuring you've got the latest version available.
Register the dokku-meteor plugin:
dokku plugin:install https://github.com/JarnoLeConte/dokku-meteor.git
This plugin will look for the presence of /home/dokku/my-app-name/meteor-settings.json and will attempt to load it at runtime. You can either connect to the server and write the file at the above path or you can use the scp command to secure copy from your local machine.
Configuring Meteor Settings
If you create a/home/dokku/my-app-name/meteor-settings.json on the server, it will be picked up during the startup phase. This is preferred to storing sensitive values in your source code repository.
Set up SSL as described here. During testing, you can use a self-signed cert.
See Deploying via Git to a Dokku Server to learn how to configure your Git deployment remote.
FAQs / Troubleshooting
Are there faster alternatives?
You can use a Dockerfile approach to bundle and deploy your artifacts as a Docker image either locally or in a CI environment and then reference this image when deploying to Dokku. Also, larger machines (with at least 2 cores) will get you much better build times.
My deploy timed out.
Git runs over SSH. During a deploy, the build process can contribute to an idle SSH connection. Your server is configured to wait up to 10 minutes before an idle connection is dropped. See the troubleshooting section on this page for a solution.
The CPU on my server is at 100% during a deploy.
You can limits on resource utilization for the Docker build process:
dokku docker-options:add my-app-name build "--cpu-quota 75000 --memory-swap -1"
The above ensures that the Docker build container never spikes above 75% and that use of memory swap is unlimited.
I see a bunch of old Docker processes on the server.
You can clean these up with dokku cleanup.