Continuous Deployment with AWS, Dokku & CircleCI

Get your Dokku server up and running in AWS

Host dokku
User ubuntu
HostName <the elastic ip>
port 22
IdentityFile ~/.ssh/example.pem
ssh dokku
wget https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh;
sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh
# If you don't already have a ssh keypair, you'll need to run this:
# ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
cat ~/.ssh/id_rsa.pub | ssh dokku sudo dokku ssh-keys:add ubuntu
ssh dokku
dokku apps:create 00-default
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
dokku letsencrypt:cron-job --add

Deploy a new app

  1. Register the app on the server
ssh dokku
dokku apps:create my-app
dokku ps:set-restart-policy my-app always
  • The npm start script is specified in package.json
  • The server listens on process.env.PORT not a hardcoded port number
cd my-app
git remote add dokku dokku@dokku.example.com:my-app
git push dokku master
ssh dokku
dokku domains:add my-app my-app.com www.my-app.com
dokku config:set --no-restart my-app DOKKU_LETSENCRYPT_EMAIL=x@x.com
dokku letsencrypt my-app

Configure CircleCI

  • Sign in to circleci.com and click “Add Projects”
  • Find the repo for your app and click “Build project”
ssh dokku
cd ~/.ssh
ssh-keygen -t rsa # save as circleci.id_rsa
sudo dokku ssh-keys:add circleci ./circleci.id_rsa.pub
cat ~/.ssh/circleci.id_rsa
deployment:
production:
branch: master
commands:
- git remote add production dokku@dokku.example.com:my-app
- git push production master

--

--

--

Full Stack JavaScript Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Reimplementing JavaScript Array methods

Type-checked and maintainable CSS using aphrodite with Next.js —(1)

Two way SSL encryption using nodejs

Gumroad Embeds not working with Cloudflare

Using useContext and useReducer together: Let’s create ‘Redux-like’ global state in React

Function Declarations vs Function Expressions — Summed Up

How to build a web app with GraphQL, Apollo & React (Part I)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Will Schmid

Will Schmid

Full Stack JavaScript Engineer

More from Medium

AWS Dynamo DB Local Development using Localstack and Docker

Two way SSL encryption using nodejs

Serverless framework — manage lambda function package

Mocking an API with Rapidmock