Skip to content

Getting a working copy of Hydroshare

Stephanie Mills edited this page Jan 15, 2014 · 6 revisions

This document is part of the Hydroshare Developers' Guide.

You can of course get Hydroshare through the GitHub repository. However, Hydroshare has many moving parts, and getting it up and running can be a chore. You may just want to get started. This guide will get you a running Hydroshare instance with the latest code as quickly as possible.

You will need PostgreSQL client programs (psql) for this guide.

1. Getting Docker

Docker, according to its website, is "an open source project to pack, ship, and run any application as a lightweight container."

To use Docker to get started with Hydroshare, you can begin by reading the Getting Started with Docker page. Additionally, Docker offers a tutorial, installation instructions, and extensive documentation.

Docker's recommended installation path is Ubuntu linux, but installation paths and instructions for Arch Linux, Gentoo, Fedora, FrugalWare, and others are available. On other operating systems, you will have to use a Ubuntu virtual machine in order to use Docker. Instructions to do this are available for Mac and Linux, Windows, Amazon EC2, Rackspace, and Google Cloud.

2. Getting Hydroshare

2.1 Get the Redis container running:

$ docker pull dev.hydroshare.org:5000/redis
$ docker run -d -name hydroshare-redis dev.hydroshare.org:5000/redis

2.2 Get the PostGIS container running:

$ docker pull dev.hydroshare.org:5000/postgis
$ docker run -d -name hydroshare-postgis dev.hydroshare.org:5000/postgis

2.3 Get the Hydroshare container running:

$ docker inspect hydroshare-redis | grep IPAddress

You should see something like this:

IPAddress: 174.14.0.2

Write this down. Now get the PostGIS address:

$ docker inspect hydroshare-postgis | grep IPAddress

You should see a similar line containing the address of the PostGIS container you just started. Now you have the PostGIS and Redis host names. Next you need to create a PostGIS database:

$ createdb -U docker -h $POSTGIS_HOST docker
$ psql -U docker -h $POSTGIS_HOST docker
> create extension postgis;
> ... exit out of the database client with CTRL-D

Now you have a working PostGIS database running on your machine as a local container with the database that Hydroshare expects to use. From here, you should follow this pattern, substituting in the PostGIS and Redis host in place of the ellipses:

$ docker run -t -i -name hydroshare-sandbox \
    -e POSTGIS_HOST=... -e REDIS_HOST=... \
    dev.hydroshare.org:5000/hydroshare /bin/bash
root@0cf8199c1 $ su docker
docker@0cf8199c1 $ cd /home/docker/hydroshare
docker@0cf8199c1 $ git pull
docker@0cf8199c1 $ python manage.py syncdb
docker@0cf8199c1 $ python manage.py migrate 
docker@0cf8199c1 $ exit
root@0cf8199c1 $ exit
$ docker commit hydroshare-sandbox my-hydroshare

3 Get a working copy on your machine to edit

$ cd ~
$ git clone https://github.com/hydroshare/hydroshare2
$ docker run -d -p 80 -p 8000 -export 23 -name my-session \
      -e POSTGIS_HOST=... -e REDIS_HOST=...\
      -v $HOME/hydroshare2:/home/docker/hydroshare:rw
      my-hydroshare /home/docker/hydroshare/init

4 View your hydroshare instance in your browser

You should now be able to surf to your Hydroshare instance on your localhost.

You can also ssh to your Hydroshare instance to work there if you want. The username is docker and the password is docker. Because you have -exposed the port rather than mapped it to an external port on your machine, the ssh is only available to you and no-one else. To find out where to ssh to, do another docker inspect my-session | grep IPAddress. The result will be the (local) IP address where you can find your Hydroshare instance.