Advertisement
Guest User

Untitled

a guest
May 24th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. # Launch a database in production and connect to it inside local nanobox app.
  2.  
  3. ##### Create a boxfile with just a database and deploy
  4.  
  5. boxfile.yml
  6. ```yaml
  7. run.config:
  8. # set your engine like normal
  9. engine: none
  10.  
  11. # define database desired in production
  12. data.db:
  13. image: nanobox/postgresql:9.5
  14.  
  15. # not necessary for launching database only, but add for `deploy dry-run`
  16. web.thing:
  17. start: sleep 1d
  18. local_only: true
  19. ```
  20.  
  21.  
  22. ##### Deploy your database with nanobox
  23.  
  24. ```sh
  25. nanobox remote add <myapp>
  26. nanobox deploy
  27. ```
  28.  
  29. Depending on your setup, you can run `nanobox tunnel data.db` from your workstation and connect to it from within your local app.
  30.  
  31. Terminal 1
  32. ```sh
  33. nanobox tunnel data.db
  34. # listening on port 5432
  35. ```
  36.  
  37. Terminal 2
  38. ```sh
  39. # Add database variables from dashboard
  40. nanobox evar add local REMOTE_DB_NANOBOX_USER=nanobox,REMOTE_DB_NANOBOX_PASS=password
  41. nanobox run
  42. #...
  43. # connect to your db
  44. psql -h 192.168.99.1 -U nanobox -d gonano
  45. # Password for user nanobox:
  46. # psql (9.5.6)
  47. # Type "help" for help.
  48. #
  49. # gonano=#
  50. ```
  51.  
  52. Alternatively, you can always download the linux version of the cli into your web container and `tunnel` from within that `nanobox run` and work in another terminal.
  53.  
  54. **Note:** *This was tested on linux with docker-machine (virtualbox), ymmv*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement