Skip to content

Instantly share code, notes, and snippets.

@linjunpop
Last active September 11, 2024 10:21

Revisions

  1. linjunpop revised this gist Oct 14, 2013. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions deploy-rails-4-app-with-dokku-on-digital-ocean.md
    Original file line number Diff line number Diff line change
    @@ -100,3 +100,14 @@ Then visit `http://[SERVER_IP_ADDRESS]:49153`

    Yeah!

    ## Config Nginx

    http://wiki.nginx.org/HttpProxyModule

    ```
    location / {
    proxy_pass http://localhost:49153;
    proxy_set_header X-Real-IP $remote_addr;
    }
    ```

  2. linjunpop revised this gist Aug 16, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy-rails-4-app-with-dokku-on-digital-ocean.md
    Original file line number Diff line number Diff line change
    @@ -96,7 +96,7 @@ root@085f103bec8a:~# RAILS_ENV=production rake db:migrate
    == AddDeviceTypeToCustomers: migrated (0.0075s) ==============================
    ```

    Then visit the http://[SERVER_IP_ADDRESS]:49153
    Then visit `http://[SERVER_IP_ADDRESS]:49153`

    Yeah!

  3. linjunpop revised this gist Aug 16, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions deploy-rails-4-app-with-dokku-on-digital-ocean.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@

    ## Install dokku

    First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

    Then ssh with root account, run this in termianl:

    ```bash
    $ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
    ```
  4. linjunpop renamed this gist Aug 16, 2013. 1 changed file with 0 additions and 0 deletions.
  5. linjunpop revised this gist Aug 16, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup-dokku-on-digital-ocean.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Setup dokku on DigitalOcean
    # Deploy Rails 4 app with Dokku on DigitalOcean

    ## Install dokku

  6. linjunpop revised this gist Aug 16, 2013. 1 changed file with 80 additions and 3 deletions.
    83 changes: 80 additions & 3 deletions setup-dokku-on-digital-ocean.md
    Original file line number Diff line number Diff line change
    @@ -14,8 +14,85 @@ $ cat ~/.ssh/id_rsa.pub | ssh [email protected] "gitreceive upload-key dokku"
    $ git remote add dokku git@[SERVER_IP_ADDRESS]:[APP_NAME]
    ```

    ## Deploy
    ## Deploy Rails app

    Add `gem 'rails_12factor'` to `Gemfile`


    Then install dokku PG plugin: https://github.com/Kloadut/dokku-pg-plugin

    ```bash
    cd /var/lib/dokku/plugins
    git clone https://github.com/Kloadut/dokku-pg-plugin postgresql
    dokku plugins-install
    ```

    Create app database

    ```bash
    root@mg-dokku:~# dokku postgresql:create [APP_NAME]
    ```

    Then `$ git push dokku master` to deploy.

    When it finished, run `$ docker ps -a` to show status:

    ```bash
    root@mg-dokku:~# docker ps -a
    ID IMAGE COMMAND CREATED STATUS PORTS
    290ae95c5ae7 app/mg:latest /bin/bash -c /start 3 minutes ago Up 3 minutes 49153->49153
    1b79bc29ae77 postgresql/mg:latest /usr/bin/start_pgsql 6 minutes ago Up 6 minutes 49156->5432
    root@mg-dokku:~#
    ```

    But we have not run database migrations yet. Let's do it:

    ```bash
    $ git push dokku master
    ```
    root@mg-dokku:~# docker run -i -t app/mg /bin/bash
    root@085f103bec8a:/# cd app/
    root@085f103bec8a:/app# RAILS_ENV=production rake db:migrate
    Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
    ```

    It fails, we try another way:

    ```bash
    root@mg-dokku:~# docker run app/mg /bin/bash -c "cd /app ; rake db:migrate"
    rake aborted!
    Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
    ```

    Fails too. :(

    Here's a workaround: https://github.com/progrium/dokku/issues/156#issuecomment-22330945

    ```bash
    root@085f103bec8a:/app# export HOME=/app
    root@085f103bec8a:~# for file in /app/.profile.d/*; do source $file; done
    root@085f103bec8a:~# hash -r
    root@085f103bec8a:~# cd /app
    root@085f103bec8a:~# RAILS_ENV=production rake db:migrate
    == DeviseCreateAdmins: migrating =============================================
    -- create_table(:admins)
    -> 0.0125s
    -- add_index(:admins, :email, {:unique=>true})
    -> 0.0034s
    -- add_index(:admins, :reset_password_token, {:unique=>true})
    -> 0.0039s
    == DeviseCreateAdmins: migrated (0.0229s) ====================================

    == CreateCustomers: migrating ================================================
    -- create_table(:customers)
    -> 0.0079s
    == CreateCustomers: migrated (0.0087s) =======================================

    == AddDeviceTypeToCustomers: migrating =======================================
    -- add_column(:customers, :device_type, :string, {:default=>""})
    -> 0.0068s
    == AddDeviceTypeToCustomers: migrated (0.0075s) ==============================
    ```

    Then visit the http://[SERVER_IP_ADDRESS]:49153

    Yeah!

  7. linjunpop revised this gist Aug 16, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions setup-dokku-on-digital-ocean.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,10 @@ $ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bas
    $ cat ~/.ssh/id_rsa.pub | ssh [email protected] "gitreceive upload-key dokku"

    $ git remote add dokku git@[SERVER_IP_ADDRESS]:[APP_NAME]
    ```

    ## Deploy

    ```bash
    $ git push dokku master
    ```
  8. linjunpop created this gist Aug 16, 2013.
    17 changes: 17 additions & 0 deletions setup-dokku-on-digital-ocean.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Setup dokku on DigitalOcean

    ## Install dokku

    ```bash
    $ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
    ```

    ## Config dokku

    ```bash
    $ cat ~/.ssh/id_rsa.pub | ssh [email protected] "gitreceive upload-key dokku"

    $ git remote add dokku git@[SERVER_IP_ADDRESS]:[APP_NAME]

    $ git push dokku master
    ```