- Schema file
- Preliminary implementation via Phoenix (Elixir) + Absinthe
Prerequisites:
- Elixir 1.7+
- Erlang / OTP 20+
To start your Phoenix server:
- Run
mix install
to install dependencies - Run
mix start
to start the server onlocalhost:4000
Prerequisites:
- Docker 17.05+
To build and run the service in Docker:
- Run
docker build .
to create a production-ready Docker image via multi-stage build, accessible onlocalhost:4000
- Run
docker-compose up -d
to run the complete solution (GraphQL and database service) in the background - Run
docker-compose up db -d
to run only the database service in the background - Run
docker-compose stop
to stop all running services
Prerequisites:
- Database backup file (archive format)
- Database service container up and running from
docker-compose.yml
- Existing
ROLE
ID in the backup to recreate
First we need to copy the database backup into the database service container:
- Run
docker ps
to get the running database service container ID - Run
docker cp ~/<database backup archive file> <container ID>:/tmp
to copy the backup file into the container - Run
docker exec -it <container ID> bash
to login and start with bash in container
In the container, before restoring, we need to prepare the out-of-the box schema:
- Run
psql -U postgres -d postgres -c 'DROP SCHEMA public'
to drop the defaultpublic
schema, it will be recreated during the restore process - Run
psql -U postgres -d postgres -c 'CREATE ROLE <role ID> WITH LOGIN ENCRYPTED PASSWORD 'S3cret!';'
to recreate the same role as found in the backup
In the container, after preparation, we can run the following command to restore the database in full:
- Run
pg_restore -U postgres -d postgres -1 /tmp/<database backup archive file>
to restore the backup