Skip to content

Instantly share code, notes, and snippets.

@patperu
Last active February 24, 2016 07:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patperu/31dc99cb478b932184e7 to your computer and use it in GitHub Desktop.
Save patperu/31dc99cb478b932184e7 to your computer and use it in GitHub Desktop.
Setup CouchDB at DigitalOcean via R
# DigitalOcean Token 'DO_PAT' set in '.Renviron'
library('analogsea')
(dr <- droplets())
# $`Old`
# <droplet>Old (12344556)
# IP: 46.AAA.BBB.CC
# Status: active
# Region: Frankfurt 1
# Image: Docker 1.8.3 on 14.04
# Size: 512mb
droplet(dr[[1]]$id) %>% summary
# <droplet_detail>Old (12344556)
# Status: active
# Region: Frankfurt 1
# Image: Docker 1.8.3 on 14.04
# Size: 512mb ($0.00744 / hr)
# Estimated cost ($): xxx
# Locked: FALSE
# Created at: xxx
# Networks:
# v4: ip_address (XXX), netmask (XXX), gateway (XXX), type (public)
# v6: none
# Kernel: id (5287), name (Ubuntu 14.04 x64 vmlinuz-3.13.0-58-generic-docker-memlimit), version (3.13.0-58-generic)
# Snapshots: 123456789
# Backups:
keys()
# $`A`
# <key> A (5221239)
# Fingerprint: 08:0b:b7:f3:.....
# $`B`
# <key> B (12344567)
# Fingerprint: f4:d2:f7:ce:.....
k <- key_create("test", readLines("~/.ssh/id_rsa.pub"))
k
# $test
# <key> test (679897)
# Fingerprint: 50:a7:fb:4b:....
d <- docklet_create(size = getOption("do_size", "1gb"),
region = getOption("do_region", "fra1"),
ssh_keys = getOption("do_ssh_keys", "test"))
d
# <droplet>AcademicCloseness (38747444)
# IP: 46.XXX.YYY.ZZ
# Status: new
# Region: Frankfurt 1
# Image: Docker 1.10.1 on 14.04
# Size: 1gb
(dr <- droplets())
# $`Old`
# <droplet>Old (12344556)
# IP: 46.AAA.BBB.CC
# Status: active
# Region: Frankfurt 1
# Image: Docker 1.8.3 on 14.04
# Size: 512mb
# $AcademicCloseness
# <droplet>AcademicCloseness (38747444)
# IP: 46.XXX.YYY.ZZ
# Status: active
# Region: Frankfurt 1
# Image: Docker 1.10.1 on 14.04
# Size: 1gb
# pull docker image
d %>% docklet_pull("klaemo/couchdb:latest")
# Warning: Permanently added '46.XXX.YYY.ZZ' (ECDSA) to the list of known hosts.
# latest: Pulling from klaemo/couchdb
# 03e1855d4f31: Pulling fs layer
# ....
# ....
# ....
# e9c8309d4a9e: Pull complete
# Digest: sha256:d33822ecaae2e6247243b24c5c72c525714d77b904105f71679fbad04756bc96
# Status: Downloaded newer image for klaemo/couchdb:latest
d %>% docklet_run("-d", " -p 5984:5984", " -e USER=doqtl", " -e PASSWORD=supersecret ", "klaemo/couchdb:latest")
# 2464609f9cf1737508ed804b3354b1607e33867d6a8f1422739f98c61920020a
library('sofa')
cushion(name = 'docouch',
base = "http://46.XXX.YYY.ZZ",
port=5984,
type = NULL)
ping('docouch')
# No encoding supplied: defaulting to UTF-8.
# $couchdb
# [1] "Welcome"
# $uuid
# [1] "a3c708ac9f1bb0c3da6da2554af6f3b7"
# $version
# [1] "1.6.1"
# $vendor
# $vendor$name
# [1] "The Apache Software Foundation"
# $vendor$version
# [1] "1.6.1"
# missing cushion name
db_create(dbname='sofadb')
# Error in sofa_PUT(sprintf("http://127.0.0.1:%s/%s", cushion$port, dbname), :
# Precondition Failed (HTTP 412).
db_create('docouch', dbname='sofadb')
# No encoding supplied: defaulting to UTF-8.
# $ok
# [1] TRUE
db_list('docouch')
# No encoding supplied: defaulting to UTF-8.
# [1] "_replicator" "_users" "sofadb"
bulk_create(iris, 'docouch', 'sofadb')
#[[150]]
#[[150]]$ok
#[1] TRUE
#[[150]]$id
#[1] "da68723c36514ce3716892a043048d29"
#[[150]]$rev
#[1] "1-b8e10ae1ecbdaded680b235da4e4184f"
@sckott
Copy link

sckott commented Feb 16, 2016

looks great!

@patperu
Copy link
Author

patperu commented Feb 24, 2016

Yes! But I am just standing on the shoulders of giants 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment