This repository is for my own personal learning journey with SurrealDB following the SurrealDB Fundamentals course. I will be using this repository to learn and experiment with SurrealDB, and I will be documenting my experiences and initial impressions along the way on my website. Eventually I would like to apply this technology to a personal project, but for now I will be using it as a sandbox to learn and experiment.
Feel free to clone or learn from this repository, but please note that it is not intended for production use.
- SurrealDB Deal Store
- Table of Contents
- Prerequisites
- Getting Started
- Resetting Docker
- References
- License
You'll basically need a working Docker environment to run the SurrealDB server.
- Docker To manage the images and run the
surreal
commands - docker-compose To manage surrealdb and infrastructure
- Docker Desktop for Windows/WSL Required for Windows users
- Surrealist
NOTE: I use nix-direnv to manage my development environment. This also let's me use commands directly from the CLI. This is optional.
NOTE: Let root
mean the root of the repository. Represented as ~/surreal-db-store/
- Clone this repository and navigate to the root
- Create a
data
directory (if not already present) at the root:mkdir ./data
- Create a
.env
at the root, and replace the content with your settingsDB_USER=<your_choice_of_username> DB_PASS=<your_very_secure_password> DB_HOST=0.0.0.0 DB_PORT=8000
- Build and run the project:
docker-compose up --build --detach
- Validate
HTTP 200
status code by making a request tolocalhost:8000
. Refer to your.env
for connection details.- Linux:
curl -v localhost:8000
- Windows:
iwr "localhost:8000" | FT StatusCode, StatusDescription
- Linux:
- Launch Surrealist and create a connection to the database
- ???
- Profit
This is mostly aimed at those who utilize Docker Desktop for Windows/WSL. If you are using Docker on Linux, you can skip this section. Clearing the Docker cache doesn't always work through the Docker Desktop GUI, so you may need to use the CLI to get the job done. At least, in my own experience.. So here are some helpful commands all aimed at stopping and removing your local docker infrastructure.
- Stop all containers:
docker stop $(docker ps -a -q)
- Remove all containers:
docker rm $(docker ps -a -q)
- Remove all images:
docker rmi $(docker images -q)
- Remove all volumes:
docker volume rm $(docker volume ls -q)
- Remove all networks:
docker network rm $(docker network ls -q)
- Remove all dangling volumes:
docker volume rm $(docker volume ls -qf dangling=true)
- Remove all dangling networks:
docker network rm $(docker network ls -qf dangling=true)
- Remove all dangling containers:
docker rm $(docker ps -a -q --filter "status=exited" --filter "status=created")
- Remove all dangling images:
docker rmi $(docker images -f "dangling=true" -q)
- Remove everything:
docker system prune -a --volumes
- SurrealDB Documentation
- Surrealist Documentation
- Docker Desktop
- docker-compose cheatsheet
- Windows Subsystem for Linux (WSL)