I'm trying to get my head around a the development workflow for working with microservices and docker multicontainer applications.
The thing that I'm particularly trying to solve - is getting a good 'live reload' workflow going for development.
For my frontend I can use webpack-dev-server which automatically reloads the page everytime I save changes. This makes it easy to write front end code quickly - with no waiting for deployments.
However - if the frontend is displaying some data retrieved from a REST API, I'm likely going to be running either a development version of that API (that itself is live reloading with nodemon, or similar) or a mocked API. This is easy enough to achieve with webpack using the proxy configurations for development environment.
For my REST API - I similarly might want to be mocking other microservices. For example if my REST API had a POST endpoint for saving an image - and I'm going to save that to an AWS S3 bucket, via the aws-sdk, I'm likely to want to be mocking that functionality.
Essentially - what it looks like - is that for every (or most) microservices - I'm also going to want to create a mock version of it.
What I imagine my workflow would look like, is something like this:
- On the front end I create a button that submits an image to the backend. I check that the POST request is being made properly.
- On my REST API, I create an end point that receives the POST request. I click the front end button and check that the backend is recieving it.
- I create a backend microservice to make AWS SDK calls. I wire it to point to a real development AWS bucket. I wire the POST endpoint to submit the image to this microservice. I click the frontend button and check that it ends up in the S3 bucket.
- But submitting this image is too slow, so I create a mock version of the AWS SDK service. I switch the REST API to use that one instead.
- On the frontend I now write some functionality to display a 'image saved!' confirmation message.
My question is:
- Is this a standard way of doing things, or am I going way off base?
- Is there a way in docker to quickly switch between whether I'm using the real microservice or the mocked one?