This directory shows an example backend and a frontend that share a TypeScript project.
The microservice under the backend directory is essentially the same as in the microservices-example.
This example adds a React-based TypeScript frontend under the frontend subdirectory.
The library my-library under the libs subdirectory is shared between the backend and the frontend, again we are using TypeScript project references.
This diagram illustrates the basic structure of this project:
cd my-project
docker build ../.. -f ./Dockerfile -t hello-worldThe Dockerfile my-project/Dockerfile has multiple build stages that compile the TypeScript code for the my-project microservices and the my-library TypeScript library.
Note that we are building the Dockerfile against the parent directory (..) and specifying the filename of the Dockerfile directly using the -f argument. We have to make the Docker build context the parent directory so that the code under the libs directory can be included in the Docker build process.
To check out how the application is structured in the built image, open a shell to it then have a look around:
docker run --rm -it hello-world shdocker run hello-worldcd frontend
npm startcd frontend
npm run buildPlease checkout frontend/package.json and you'll see how we run tsc --build to build the shared libraries before invoking Parcel to bundle the frontend.
