Deploy
DocPad websites can be deployed anywhere. Here are a few of the most common deployments.
Deploying DocPad
Preparing DocPad for Deployment
Ensure your project's
package.jsonfile contains the following:"engines" : { "node": "6", "npm": "3" }, "dependencies": { "docpad": "6", "docpad-plugin-blah": "2" }, "main": "node_modules/.bin/docpad-server", "scripts": { "start": "docpad-server", "test": "docpad generate --debug --silent --env static", "info": "docpad info --silent" }Correct dependencies with what you are actually using.
To Static Servers (Apache, Nginx, etc.)
For deployment to a Custom Static Server
Perform a generation for a static production environment using
docpad generate --env staticUpload the generated directory to your server's
public_htmlorhtdocsdirectoryIf you use rsync, checkout our DocPad rsync deploy script
For deployment to GitHub Pages
Install the GitHub Pages Plugin
Deploy to GitHub Pages using the plugin
If you'd like deployment automatically to GitHub Pages every time your repo updates, check out the Continuous Deployment Guide
For deployment to a Cloud Data Storage Provider (AWS S3, Google Storage, etc.)
To a Node.js Hosting Provider
For deployment to Heroku
Create a
Procfilefile inside your project that contains:Set your heroku instance to run in production mode
If you're also wanting to use custom domains for your website, follow the Heroku Guide here, or alternatively here is a generic guide:
Login to your domain's DNS manager
Create an CNAME Record for your domain pointing to your app url (e.g.,
balupton.herokuapp.com)
For deployment to OpenShift
Create your OpenShift account and install their client tools
Create a new OpenShift application for your project:
Set environment variables using:
If you'd like a custom domain, run:
Then create CNAME record with your DNS host pointing
PROJECTWEBSITE.COMtoPROJECTNAME-YOUR_OPENSHIFT_NAMESPACE.rhcloud.comIf you don't know what your OpenShift namespace is, run:
And it will be listed within the SSH URL.
Deploy your project's code to openshift:
You should be all good now! Check the logs of your app with:
For deployment to Windows Azure
Create a deployment script that triggers the static content generation. To create the script run the following command using the Windows Azure Cross-Platform Command-Line Interface:
Modify the
deploy.shfile by changing the# Deploymentsection to the following lines. You can see a complete example of the deploy.sh file here.Last, create a
web.configfile in thestaticdirectory of your site with the URL rewrite rules shown below. These rules remove the HTML extensions from your URLs. You can see the main portions of thisweb.configfile below. You can download the complete file here.
For deployment to Modulus
For deployment to Docker
Continuous Deployment
To GitHub Pages
Inside your project directory, do the following:
Add the GitHub Pages Plugin as a Development Dependency
Add a deploy script to your
package.json"scripts"section:Remove the
regenerateEveryproperty from your DocPad Configuration File if you have set it, as it will no longer be needed.
Using Travis CI
Inside your GitHub account, do the following:
Create a Personal Access Token called
Travis CI Deployerthat hasrepoandpublic_repochecked (uncheck everything else), make note of the token we'll use it later (this same token can be used for all the repos you have access to).
Enable Travis CI for the repository, then inside the repository directory, do the following:
Add this
.travis.ymlfile to your project (make any necessary changes to the Custom Configuration section).Run the following commands (with the appropriate substitutions):
Commit and push the changes.
If you want to regenerate your website when an external GitHub Repository changes (for instance updating the DocPad Website when the DocPad Documentation repository changes), you will need to Enable Travis CI for that repository, then inside that repository directory, do the following:
Add this
.travis.ymlfile to your project (make any necessary changes to the Custom Configuration section).Run the following commands (with the appropriate substitutions):
Commit and push the changes.
All done, your next push to master will be automatically deployed.
Using Circle CI
Inside your project directory, do the following:
Add this
circle.ymlfile to your project (make any necessary changes to the Custom Configuration section).Commit and push the changes.
Create a SSH Key that will be used by Circle CI to deploy to GitHub Pages, do this by:
Create the SSH Key, make note of where it goes, don't bother with a password, use the email that was inside your
circle.ymlfile:Make note of it's location. Two files will be generated. One with
.pubat the end, which is the public key, and one without.pubwhich is the private key.
Inside your Circle CI account, do the following:
Add any environment variables you may need via
Project Settings -> Tweaks -> Environment VariablesAdd the private key to CircleCI via
Project Settings -> Permissions -> SSH Permissions. Set the hostname togithub.com. Use the contents of the private key file for the private key text area.
Inside your GitHub Project Settings, do the following:
Add the public key to your GitHub Project by going to
Settings -> Deploy Keys -> Add deploy key. Specify the title asCircleCI Deploymentor whatever you like and set the key text area to the contents of the public key. Allow write access.
If you want to regenerate your website when an external GitHub Repository changes (for instance updating the DocPad Website when the DocPad Documentation repository changes), you will need to:
Create yourself a Circle CI token via the Circle CI Account API Page
Go to the settings of the GitHub Repository that should cause the regeneration, and access
Webhooks & Services -> Add webhookSpecify the
Payload URLto be:Specify
Content typeto beapplication/json, selectJust the push event, and checkActiveYou can hit that Payload URL whenever you want to retest and rebuild your project.
All done, your next push to master will be automatically deployed.
You can now delete the local SSH key files that were made, as they serve no further purpose.
To GitLab Pages
Project repository must be at GitLab. If it is already somewhere else, GitLab allows to setup automatic mirroring.
Just add single file .gitlab-ci.yml to project root:
Last updated
Was this helpful?