Developing a RESTful API to manage Docker Containers
This section is the most important one, trying to understand what's happening
Yes! Of course there is, how could I even ask that question?
Develop a REST API to manage Docker Containers, with the following actions:
- Create
- Read
- Update (???)
- Delete
and learn something new (or improve it)!
- App
- Status (health check BABYYYYYYYY!!!)
- Container (keeping it simple)
- Status
- Name
- Ports
- Image
- ID
- CreatedAt
Right now(didn't wrote a line of code yet)? Yes, sound good
Making it simple and working
- Write Code
- Write Tests
- Run the Tests
- Failed? Fix it
- Success? Go to the first line, and repeat
- Logging: uber-go/zap
- Low allocation
- Easy to use/implement
- Great docs
- Well maintained
- Web Framework: gofiber/fiber
- User friendly (express-like)
- Great docs
- Well maintained
- Because I'm not implementing Swagger, it should be fine.
- Testing Toolkit: stretchr/testify
- Easy to use/implement
- Support for Suite Testing
- Great docs
- Well maintained
- Docker Client: docker/client
- Official Client to communicate with the Docker Engine API
- Receive API request
- Validate the request
- "Mount" the Data model
- Create the Container
/health
- Check connections
/container
- Route/create
- POST- Create a Container
- Retrieve all Containers
?image=
- GET- Retrieve all Containers by image
/:name
- GET- Retrieve Container by name
/:name
- PUT/PATCH- Update Container with given name
/:name
- DELETE- Update Container with given name
This section is not as important as the first one, but could bring greater quality to the app.
- Write code
- Run the tests
- Failed? Fix it
- Success? Go to the first line, and repeat
- Tests:
- Check the coverage
- If it's only Unit Tests, what about Feature Tests?
- Container CRUD:
- More options to customize the Container
- Controller
- Concurrency?
- Race Condition
- Make it safe/safer
- Concurrency?
This part is just for funsies, to see where I can reach while having fun.
- Container CRUD:
- CPU/MEM Limit
- Observer
- Keep checking all containers (maybe Docker API has somewhere that we can Sub)
- Internal Storage
- Can be a JSON file, no need to be fAnCy
- Only check the containers created by my Controller
- gRPC Server
- What if we had a notification system
- e.g:
container XYZ broke
- e.g
container XYZ memory/CPU usage surpassed 30%
- e.g:
- What if we had a notification system