Top Banner
Digital Ocean Meetup What I do with my $5 (per month actually)
45
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Do meetup

Digital Ocean Meetup

What I do with my $5 (per month actually)

Page 2: Do meetup

IntroductionAbout me? Or about Digital Ocean?

Page 3: Do meetup

What I’m going to talk about

Page 4: Do meetup

So why DO?

Page 5: Do meetup

The Adverts

Page 6: Do meetup

Price?

Page 7: Do meetup

Easy?

Page 8: Do meetup

Performance?• Sorry no picture.• Benchmarks gives some indication, but hard to

make it really objective and useful.• Location. DO has no Asia servers.. yet.

Page 9: Do meetup

It depends.Cliché I know.

Page 10: Do meetup

Experience with DO• I have a website: www.dilegno.sg

• Some parts of Shoppink use Digital Ocean

• Plus my random stuff I’m going to share with you

Page 11: Do meetup

Alternatives?Many.

Page 12: Do meetup

Setting up DO

Page 13: Do meetup

One

Page 14: Do meetup

Two

Page 15: Do meetup

That’s it!

Page 16: Do meetup

A website

Page 17: Do meetup

Recipe• A personal website.• Simply get a web server running (apache or

nginx)• My website uses Sinatra. • We then need to get nginx talking to Sinatra.

Page 18: Do meetup

Sinatra• Sinatra is a Ruby micro-framework

• require 'sinatra'

get '/hi' do "Hello World!"

end

Page 19: Do meetup

Unicorn# set path to app that will be used to configure unicorn, # note the trailing slash in this example@dir = "/home/sockmister/personal-website/"

worker_processes 1working_directory @dir

timeout 30

# Specify path to socket unicorn listens to, # we will use this in our nginx.conf laterlisten "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64

# Set process id pathpid "#{@dir}tmp/pids/unicorn.pid"

# Set log file pathsstderr_path "#{@dir}log/unicorn.stderr.log"stdout_path "#{@dir}log/unicorn.stdout.log"

Page 20: Do meetup

Nginx• sudo apt-get install nginx• We can start, stop, restart by

o sudo service nginx restart|start|stop|status

• We then write the config files.

Page 21: Do meetup

The Idea• The apps we are running today run behind nginx.

Nginx

App1

App2

App3

Incoming Requests

Outgoing Replies

Page 22: Do meetup

Config Fileupstream pohchiat{ server unix:/home/sockmister/personal-website/tmp/sockets/unicorn.sock;}

server { listen 80; server_name www.pohchiat.com; root /home/sockmister/personal-website/public;

location / { proxy_pass http://pohchiat; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }}

Page 23: Do meetup

Done!

Page 24: Do meetup

Free GitHub reposUsing GitLab

Page 25: Do meetup

Recipe• Setup GitLab

o Install dependencieso Setup new usero Clone and install GitLab shello Setup database (postgresql or mysql)o Setup GitLab itself

• Hook up with Nginx

Page 26: Do meetup

Dependencies• Python 2

o Sudo apt-get install python

• Rubyo Ubuntu repositories are outdatedo I use rvm to handle ruby versions.

• Gemo gem install bundler

Page 27: Do meetup

Adduser• We need to create a new user called ‘git’.

o sudo adduser --disabled-login --gecos 'GitLab' git

Page 28: Do meetup

GitLab Shell• Clone

o sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git

• Git checkout the right versiono sudo -u git -H git checkout v1.7.1

• Edit config fileo sudo -u git -H editor config.yml

• Run a scripto sudo -u git -H ./bin/install

Page 29: Do meetup

Database• Install postgresql

o sudo apt-get install -y postgresql-9.1 libpq-dev

• Logino sudo -u postgres psql -d template1

• Create user and databaseo CREATE USER git WITH PASSWORD '$password';o CREATE DATABASE gitlabhq_production OWNER git;

Page 30: Do meetup

GitLab• Clone

o sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab

• Git checkouto sudo -u git -H git checkout 6-1-stable

• Configureo Copy and change GitLab config fileo Mkdir for logs, tmp, publico Copy and change unicorn config file

• Install required Gemso gem install charlock_holmes --version '0.6.9.4'o bundle install --deployment --without development test mysql aws

• Initialize DBo sudo -u git -H chmod o-rwx config/database.ymlo bundle exec rake gitlab:setup RAILS_ENV=production

• Run as service

Page 31: Do meetup

Nginx• This time GitLab has supplied the Nginx config

file.• The idea though, is really the same.

Page 32: Do meetup

Done!

Page 33: Do meetup

E-Book manager Calibre Library

Page 34: Do meetup

Calibre LibraryThis needs a bit of intro.

Page 35: Do meetup

Calibre Library

Page 36: Do meetup

Recipe• Setup calibre app (this time it’s actually really

simple)• Setup dropbox daemon• Hook up to Nginx (same!)

Page 37: Do meetup

Setup Calibre• sudo python -c "import sys; py3 = sys.version_info[0] > 2; u =

__import__('urllib.request' if py3 else 'urllib', fromlist=1); exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read()); main()

• To start calibre server, • Sudo /opt/calibre/calibre-server• Options:• --with-library• --username• --password• --daemonize

Page 38: Do meetup

Dropbox• I run calibre on my laptop as well.• Need a simple way to sync the books both ways.• Trivia: NUS won Dropbox space race a while ago

and all NUS students have 25 GB extra space.

Page 39: Do meetup

Dropbox• Download & install

o wget -O dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86

o tar –xzvf dropbox.tar.gz

• Runo ~/.dropbox-dist/dropboxd

• Link to your Dropbox accounto This client is not linked to any account…

• Control Dropboxo wget -O ~/.dropbox/dropbox.py "http://www.dropbox.com/download?

dl=packages/dropbox.py"

Page 40: Do meetup

Done!

Page 41: Do meetup

Caveats• It’s experimental.• Just because you can, doesn’t mean you should.• 512MB RAM• Erm. I cheated. I paid for domain too.

Page 42: Do meetup

Takeaway• Tons of open source projects to try out.• It’s not a must to run this on DO.

Page 43: Do meetup

Resources• Digital Ocean has a lot of guides. A lot a lot.

Page 44: Do meetup

Otherwise…• Setup nginx

o http://ruby-journal.com/how-to-setup-rails-app-with-puma-and-nginx/o http://recipes.sinatrarb.com/p/deployment/nginx_proxied_to_unicorn

• GitLab o https://github.com/gitlabhq/gitlabhq/blob/6-1-stable/doc/install/

installation.md

• Calibre servero http://manual.calibre-ebook.com/cli/calibre-server.html

• Dropbox daemono http://ubuntuservergui.com/ubuntu-server-guide/install-dropbox-

ubuntu-server

Page 45: Do meetup

Thank you!