This write up was based on Henrik's gist
- Create a droplet on digital ocean. Use my referal link for $10 credit. I also credit if you spend money, so thanks in advance ;)
- Select "Create Droplet"
- Under "Choose an image", click on "One-click Apps"
- Select Dokku for your app
- Under "Choose a size" select at least 1GB of RAM
- Add your ssh public key
- Click "Create"
- Once your server is created, go to the IP address in your browser
- Verify the ssh key is correct.
- Click "Finish setup"
- ssh into your server (ex: ssh [email protected])
- Run these commands in the terminal.
1. Change the app_name to your application name or something like prod or qa.
1. Change app_db to your database name
1. Change SECRET_KEY_BASE="" to actual key from your
prod.secret.exs
file 1. Optional: You can copy this into a setup.sh file and run it with ./setup.sh. (Remember to change the file permissionchmod u+x ./setup.sh
)
#commands to run on your server
dokku apps:create app_name
dokku config:set app_name BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
dokku config:set app_name LC_ALL=en_US.utf8
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
dokku postgres:create app_db
dokku postgres:link app_db app_name
dokku config:set app_name SECRET_KEY_BASE="key"
Create the following file in your project root folder
- Create a file named
.buildpacks
with the following content
https://github.com/HashNuke/heroku-buildpack-elixir.git
https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
- Create a file named
elixir_buildpack.config
with the following content (change it to your setting)
erlang_version=18.2.1
elixir_version=1.2.0
always_rebuild=false
post_compile="pwd"
- Create a file named
phoenix_static_buildpack.config
with the following content (change it to your setting)
node_version=5.5.0
npm_version=3.3.12
- Open up
config/prod.exs
- Remove this line
import_config "prod.secret.exs"
(at the end of the file) to prevent it from importing prod.secret - Add
secret_key_base: System.get_env("SECRET_KEY_BASE")
underneath the main config. Ex:
```
config :blog, Blog.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/manifest.json",
secret_key_base: System.get_env("SECRET_KEY_BASE")
```
Remember to add the **comma** before adding `secret_key_base`
- Optional: Add database setting to the end of the file, change
blog
to your app name anddb_name
to your database name 1. Note you must get url fromDATABASE_URL
because that's where Dokku set your database url
config :blog, Blog.Repo,
adapter: Ecto.Adapters.Postgres,
database: "db_name",
url: System.get_env("DATABASE_URL"),
pool_size: 20
- Add a git remote
git remote add ocean dokku@ip_address:app_name
- Note you have to log in using
dokku
as the user - Ex: `git remote add ocean [email protected]:app_name
- Deploy
git push ocean master
- Optional: Setup your database
- ssh into your server
- Migrate database
dokku run app_name mix ecto.migrate
You can see all the dokku commands with dokku help
.
- https://gist.github.com/henrik/c70e32544e09c1a79841
- http://www.phoenixframework.org/docs/heroku
- http://hady.svbtle.com/setting-up-elixir-on-digitalocean
- http://wsmoak.net/2015/07/05/phoenix-on-heroku.html
- http://snltranscripts.jt.org/99/99adillon.phtml
- https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-dokku-application
- http://dokku.viewdocs.io/dokku/application-deployment/