First and foremost, this was a learning experiment — probably not something I would do on a production-level app given what I learned.

I was trying to create an API endpoint for serving Dungeons & Dragons (D&D) items data. My data would come from an existing JSON file.

I wanted to use the Phoenix framework to learn functional programming. My data would be read-only, but it had an irregular shape. Because of that I thought it would be best to use a NoSQL data store so to circumvent the complications of designing the schema for a relational database over a huge set of data with no clear relationship patterns. I picked MongoDB because it was popular, and I wanted to try it out. I picked Docker because I didn’t want to install MongoDB in my system.

Finally I wasn’t able to find any up-to-date sources online on how to get this setup running, so I decided to write one myself as part of my learning exercise.

Words of Warning

MongoDB can’t fuzzy-match on text search. This means that although it can match individual words, ie. "foobar" -> foobar works, "foobar" -> foo does not. This may make complex searching though text data very complicated, if not impossible. As I have later learned, this would make searching through my D&D items very difficult! MongoDB is not the right choice here.

Elixir runs on the Beam VM, which allows parallel execution based on how many cores exist in the machine. A Docker container may have settings that limit the maximum amount of cores available to containers, in which case may or may not be desirable for some applications. For mine, it doesn’t really matter.

All the versions

Elixir
v1.10.3

Dependencies
phoenix ~> 1.4.3
mongodb ~> 0.5.1
poolboy ~> 1.5.2
MongoDB
v4.2.6
Docker version 19.03.8, build afacb8b
docker-compose version 1.25.5, build 8a1c60f6
docker-compose.yml
version: "3.8"

#docker #programming #mongodb #phoenix

How to Setup Phoenix on Docker with MongoDB
8.10 GEEK