Local Development with Docker

Requirements

Recent version of Docker.

Domains for local development

You will need two domain to run this app. One for the public site and one for the apply site.
Add this to your /etc/hosts file.
1
127.0.0.1 hypha.test
2
127.0.0.1 apply.hypha.test
Copied!
The "test" TLD is safe to use, it's reserved for testing purposes.
OBS! All examples from now on will use the hypha.test domains.

Get the code

1
$ git clone https://github.com/HyphaApp/hypha.git hypha
2
3
$ cd hypha
Copied!
OBS! Everything from now on will happen inside the hypha directory.

Docker

Build the Docker images

Move to the "docker" directory.
1
$ cd docker
Copied!
Run the docker compose command to build the images. This will take some time.
If you need to rebuild the images to get a later version just run the "build" again.
1
$ docker-compose build
Copied!

Start the docker environment

To start the docker containers you use the "up" command. This command you will use each time you want to start up and use this docker environment.
1
$ docker-compose up
Copied!

Access the docker environment

Run commands in the docker environment

To get bash shell on the container that runs the Django app, use this command.
1
docker-compose exec py bash
Copied!
Here you can issue django commands as normal. You might want to change the user - the default is circleci, but most of the code is owned by the user 'node'. To do that:
docker-compose exec -u node py bash
To get a shell on the container that runs Postgres, use this command.
1
docker-compose exec db bash
Copied!

Stop the docker environment.

Press ctrl+c in the terminal window.

Restore a database dump in Docker

We will use the "public/sandbox_db.dump" for this example. That is a good start in any case, you get some example content etc.
First get a shell on the db container.
1
docker-compose exec db bash
Copied!
Then in that shell you need to install wget to download the db dump.
1
apt update
2
apt install wget
Copied!
Then download the sandbox db dump from Github.
1
wget https://github.com/HyphaApp/hypha/raw/sandbox/public/sandbox_db.dump
Copied!
Before being able to work on this database, you have to drop and prevent any other connections to it.
1
psql
2
# REVOKE CONNECT ON DATABASE hypha FROM public;
3
# SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'hypha';
4
# \q
Copied!
With this done, drop and then create the hypha database and run the pg restore command like this.
1
dropdb --user=hypha hypha
2
createdb --user=hypha hypha
3
pg_restore --verbose --clean --if-exists --no-acl --no-owner --dbname=hypha --username=hypha sandbox_db.dump
Copied!
Last modified 3mo ago