In this post I'll be covering setting up a dev server using a few tools including Unraid, Hasura, and PostgreSQL. This is part of an on going series that you can read about here.
The Following is a basic description of the tools I'll be using for this project.
I've been using it as the OS for my home server, it makes it easy to manage containers and VMs remotely. This is where I'll be hosting my dev environment.
I'll be using Hasura for this GraphQL endpoint. I've used it before and it's very easy to work with and includes all the features I'll need for this project.
This is that database that integrates with Hasura, I've used it for previous projects and I've been very happy with it's performance and feature set.
With that out of the way here's the setup for the environment.
Hasura and Postgres can be setup at once using docker compose as is shown in the quickstart guide. In this case I'll be setting up the containers separately in Unraid.
The setup here is very simple using unraid. It involves navigating to Docker -> Add Container. Then we select an image from dockerhub and specify all the required variables. From there the image is created and run.
A command from the terminal would look something like this, though you would need to change some parameters including the password, user and database.
docker run -d --name='Postgres13' --net='bridge' -e TZ="America/Phoenix" -e HOST_OS="Unraid" -e 'POSTGRES_PASSWORD'='pass' -e 'POSTGRES_USER'='user' -e 'POSTGRES_DB'='database' -p '5432:5432/tcp' -v '/mnt/cache/appdata/postgres':'/var/lib/postgresql/data':'rw' 'postgres:13.1-alpine'
At that point we can check the logs and see the database up and running.
The setup for Hasura is similar. Just double check that all the variables match those set in Postgres and select a port that isn't in use.
docker run -d -p 8080:8080 \ -e HASURA_GRAPHQL_DATABASE_URL=postgres://user:[email protected]:port/dbname \ -e HASURA_GRAPHQL_ENABLE_CONSOLE=true \ hasura/graphql-engine:latest
At this point can open our browser to [Unraid IP address]:[Port] and see the the Hasura console!
This is a great starting point, and from here on we can start playing with Hasura's model and GraphQL endpoint.
In the next post I'll be covering securing the endpoint and exposing it to the internet.
I hope you've found this post useful. If you have any questions or comments, please feel free to reach out!
Get In Touch
or via telegram