Docker/Wercker based Keystone.js framework, using Dokku for deployment
You must have Docker and Wercker Cli installed before beginning.
- Clone this repo
- cd into the root of the repo and run
tools/dev
The application should now be running on port 80. You will be attached to the running container and the log viewer will run.
If you need to run adhoc commands, hit ctrl+c
to exit the log viewer. You can return to the log viewer by simply running log
To exit fully from the container, hit ctrl+c
to exit the log viewer and then type exit
to exit the container.
Visit /admin
to manage the site. Use the following credentials in development:
Email: [email protected]
Password: changeme
Any environment variables which need to be supplied when developing locally can be placed in the ENVIRONMENT
file, with variable names prefixed with X_
. For any variables which you don't want adding to the repository can be added to the ENVIRONMENT_LOCAL.template
file, without the X_
prefix. If this template file is not empty, the application will not start without an ENVIRONMENT_LOCAL
file being created.
You should periodically update the node base image as new versions are released. To do so, update the node box in wercker.yml
and the base image in dokku/Dockerfile
for deployment.
The framework is setup to deploy to a Dokku instance using Wercker.
- Navigate to your project and open the
Workflows
tab - Click
Add new pipeline
- Fill in the form:
- Name - [staging/production]
- YML Pipeline name - deploy
- Hook type - default
- Click the
Create
button - On the resulting page, create a new SSH key by clicking the
Generate SSH Keys
link below and to the right of the Pipeline environment variables section:- SSH key name - DOKKU_KEY
- Create three environment variables:
- DOKKU_HOST - String - [your dokku host ip or fqdn]
- DOKKU_APP - String - keystone
- Go back to the
Workflows
tab - click the
+ icon
next the thebuild
workflow. - Enter the branch you wish to deploy, select the pipeline you just created for the execute pipeline, and click
Add
Once you've booted your Dokku server, on the installation screen, copy and paste the public SSH key from the Wercker Project target. Then run the following steps:
# Set some environment variables
export MONGO_IMAGE_VERSION="3.2.4"
# Install Mongo Dokku plugin
dokku plugin:install https://github.com/dokku/dokku-mongo.git
# Create our Keystone app
dokku apps:create keystone
# Create our Mongo service and link to our Keystone app
dokku mongo:create keystone-db
dokku mongo:link keystone-db keystone
# Create our volumes
mkdir -p /var/lib/dokku/data/keystone/cache
mkdir -p /var/lib/dokku/data/keystone/uploads
# Mount our volumes
dokku storage:mount keystone /var/lib/dokku/data/keystone/cache:/app/public/cache
dokku storage:mount keystone /var/lib/dokku/data/keystone/uploads:/app/public/uploads
# Restart our application on failure
dokku docker-options:add keystone deploy --restart=always
# Set our config values
dokku config:set keystone COOKIE_SECRET="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c64)"
dokku config:set keystone ADMIN_FIRST_NAME="[first name]"
dokku config:set keystone ADMIN_LAST_NAME="[last name]"
dokku config:set keystone ADMIN_EMAIL="[email]"
dokku config:set keystone ADMIN_PASSWORD="[password]"
dokku config:set keystone CLOUDINARY_URL="[url]"
dokku config:set keystone GOOGLE_ANALYTICS_ID="[ga_id]"
# Setup out domains
dokku domains:add keystone example.com
dokku domains:add keystone www.example.com
# Setup any ssl certificates from string, tarball or stdin
dokku certs:add keystone certs.tar