A simple Phoenix API that does a list and show of World Heritage Centre sites, sites stored in postgres, and the whole thing running on docker containers and AWS ECS.
I'm very familiar with postgres and terraform and I'm new to Phoenix. I elected to put minimal features into the API so that I could show off more of my experience in pg, docker, and terraform. Each of the directories in this repo has a more detailed README about the relevant topics.
┌───────────────────────────┐
│ Github container │
push release img │ registry │
────────────────────►│ │
│ │
└────────────────┬──────────┘
│ │
│ │
ALB│ │
│ │
│ ┌────────────────▼───────────┐
│ │ ECS │
│ │ ┌──────────────────────┐ │
│ │ │ Target Group │ │
│ │ │ │ │
│ │ │ ┌──────────────┐ │ │ ┌───────────────┐
│ │ │ │ Phoenix API │ │ │ │ Postgres RDS │
│ │ │ │ (container) │ │ │ │ │
GET │ │ │ │ │ │ │ │ │
──────────┼────────│──┼───► /api ◄───┼──│─────► │
│ │ │ │ /whcsites │ │ │ │ │
│ │ │ │ /:id │ │ │ │ │
│ │ │ │ │ │ │ │ │
│ │ │ │ /healthz │ │ │ │ │
│ │ │ │ │ │ │ │ │
│ │ │ └───────────▲──┘ │ │ └─────▲─────────┘
│ │ │ │ │ │ │
│ │ └───────────────┼──────┘ │ │
│ │ │ │ │
│ │ │ │ │
│ └──────────────────┼─────────┘ │
│ ▲ │
│ │ │
│ ┌─────────┼─────────────────────┼─┐
│ Secrets Manager │
│ - secret key base │
│ - db password │
│ │
└─────────────────────────────────┘
Locally, two containers:
- api
- postgres
The postgres conatiner uses the official postgres image with some .sql
files mounted into the initdb
directory. A container healthcheck on the database allows the api container to wait until the db is healthy before starting and trying to connect.
The api image is build from a Dockerfile
generated by the Phoenix release tooling. In docker-compose.yaml
, the local "dev" api container targets a build stage in the dockerfile that has installed all the deps and can be run in the same way as a non-containerized elixir project. For convenience, there is an api-release
service in docker compose that uses the final build stage in from the dockerfile that is a prod-ready release. This release image is pushed to github container registry for ECS to pull down later.