Last active
April 1, 2025 14:41
-
-
Save tinhnq/6f8f3ea98431d3fd4138f9f021a9ece7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Setup Server on Vultr | |
Select “create New Server(e.g. 123.123.123.123)”, select “Ubuntu 14.04 LTS” | |
Once your server has been created, wait for installation to complete. | |
SSH into your Server as root and run the following commands: | |
# login server by SSH | |
ssh [email protected] | |
# Updating apt-get | |
sudo apt-get update # Fetches the list of available updates | |
sudo apt-get upgrade # Strictly upgrades the current packages | |
sudo apt-get dist-upgrade # Installs updates (new ones) | |
# Set Timezone for Server | |
mv /etc/localtime /etc/localtime.bak | |
ln -s /usr/share/zoneinfo/Asia/Saigon /etc/localtime | |
service cron restart | |
2) Setup Swap space | |
# login server by SSH | |
ssh [email protected] | |
cat /proc/swaps | |
# Filename Type Size Used Priority | |
# create a folder for swap | |
mkdir /var/swap | |
# create 2GB swap file | |
dd if=/dev/zero of=/var/swap/swap0 bs=1M count=2048 | |
# Set permission | |
chmod 600 /var/swap/swap0 | |
# Setup swap configuration | |
mkswap /var/swap/swap0 | |
swapon /var/swap/swap0 | |
echo '/var/swap/swap0 swap swap defaults 0 0' >> /etc/fstab | |
cat /proc/swaps | |
# Filename Type Size Used Priority | |
# /var/swap/swap0 file 2097148 211176 -1 | |
3) Installation for Dokku | |
# login server by SSH | |
ssh [email protected] | |
# Installing Dokku | |
cd /tmp | |
wget https://raw.githubusercontent.com/dokku/dokku/v0.10.5/bootstrap.sh | |
sudo DOKKU_TAG=v0.10.5 bash bootstrap.sh | |
4) Submit public SSH key & domain to dokku web page | |
Open dokku.me or 123.123.123.123 by your web browser and submit public SSH key & domain name. | |
5) Install Postgress on Dokku | |
# login server by SSH | |
ssh [email protected] | |
# Install PostgreSQL plugin on dokku | |
dokku plugin:install https://github.com/dokku/dokku-postgres.git | |
#Enable Postgis | |
(sudo) docker pull mdillon/postgis:latest | |
export POSTGRES_IMAGE="mdillon/postgis" | |
export POSTGRES_IMAGE_VERSION="latest" | |
# Create instance of PostgreSQL | |
dokku postgres:create dokku_sample_db | |
# Create instance of Application | |
dokku apps:create dokku_sample_app | |
# Relate PostgreSQL instance with the application | |
dokku postgres:link dokku_sample_db dokku_sample_app | |
6) Setup DNS | |
Setup domanin & IP to your DNS | |
dokku.me A 123.123.123.123 | |
*.dokku.me A 123.123.123.123 | |
7) Set domain & IP to your hosts | |
Add your domain & IP to local /etc/hosts: | |
123.123.123.123 dokku.me | |
8) Set SSH Configuration | |
Add SSH Configuration to local ~/.ssh/config: | |
Host dokku.me | |
HostName 123.123.123.123 | |
IdentityFile ~/.ssh/id_rsa.dokku.me | |
User root | |
9) Deploy your app | |
# From your local machine | |
git clone [email protected]:heroku/ruby-rails-sample.git | |
# Each official datastore offers a `link` method to link a service to any application | |
git remote add <name> dokku@<host>:<app> | |
git remote add dokku [email protected]:ruby-rails-sample | |
# Installing dokku command line tool | |
gem install dokku-cli | |
# Set secret key for Rails | |
bundle exec rake secret | |
dokku config:set SECRET_KEY_BASE="上で生成された文字列" | |
dokku config:set CURL_TIMEOUT=1200 | |
# Deploy | |
git push origin master | |
# Show app by browser | |
dokku open | |
# Redis, Sidekiq | |
https://pawelurbanek.com/rails-heroku-dokku-migration | |
10) dokku-cli Cheat Sheat | |
# Basic Commands | |
dokku run <cmd> # Run a one-off command in the environment of the app | |
dokku ssh # Start an SSH session as root user | |
dokku logs [-t] # Display logs for the app (-t follows) | |
dokku help [COMMAND] # Describe available commands or one specific command | |
# Configuration Commands | |
dokku config # Display the app's environment variables | |
dokku config:get KEY # Display an environment variable value | |
dokku config:set KEY1=VALUE1 [KEY2=VALUE2 ...] # Set one or more environment variables | |
dokku config:set:file <path/to/file> # Set one or more environment variables from file | |
dokku config:unset KEY1 [KEY2 ...] # Unset one or more environment variables | |
# Process / Container Commands | |
dokku ps # List processes running in app container(s) | |
dokku ps:rebuild # Rebuild the app | |
dokku ps:restart # Restart the app container | |
dokku ps:start # Start the app container | |
# その他便利コマンド | |
dokku nginx:build # (Re)builds nginx config for the app | |
dokku open # Open the app in your default browser | |
dokku url # Show the first URL for the app | |
dokku urls # Show all URLs for the app | |
11) Dokku app at the root domain of the dokku server | |
# login server by SSH | |
ssh [email protected] | |
dokku domains:add myapp mydomain.com | |
Source: http://blog.morizyun.com/blog/dokku-isntall-vultr-pass-mini-heroku/ | |
Source: https://gist.github.com/shirren/f407cf76b38ee57042a554af708c0e2e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment