Scaffolding for a fullstack TypeScript application running across multiple Docker containers. Orchestrated using docker compose
.
![Screen Shot 2024-01-06 at 5 21 01 PM](https://private-user-images.githubusercontent.com/3476796/294725428-46b61fba-d026-49b3-8f9c-6fae0c6a1be0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxODUyNzEsIm5iZiI6MTcyNTE4NDk3MSwicGF0aCI6Ii8zNDc2Nzk2LzI5NDcyNTQyOC00NmI2MWZiYS1kMDI2LTQ5YjMtOGY5Yy02ZmFlMGM2YTFiZTAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkwMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MDFUMTAwMjUxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9N2ZlMjhjYzY4YTUzYzU3ZDk2NjBhY2Y1NzgyMDM1ZGI2ZmFmYzA1OGRhNjkyMzI4Y2FkNWFiNjQ0NDQ4NDMxOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.zH_XfpeCgEQ-rEo4dCCW5imkf7n_ShlQ_ZKaSgFED6k)
To start everything, simply run:
$ docker compose up -d
This create four docker containers
webpack
: bundles TS files, rebuilds on changesnginx
: serves static content, routes api requests to serverserver
: runs api serverdb
: manages a postgres instance
Navigate to localhost:8080
to see the app running. To make changes to the app, simply modify files in src
.
This project is configured to run a TypeScript typecheck on each build. If you have a type error, it will show up in the log for either the app-builder
or server-builder
containers.
However, it's sometimes nicer to get that feedback locally (or even better, in your IDE). To do so simply install the node modules locally and optionally run typescript:
$ npm install
$ npm run typecheck
This project uses prisma
as an ORM to manage db connections, create schemas and models, and run queries. It's pretty nifty and works quite well with TypeScript! See https://www.prisma.io/.
In general prisma
works as expected with the docker compose
flow.
- To run a migration, connect to the
server
container and run:
$ npx prisma migrate dev --name <migration name>
- If you want types from the generated
prisma/client
to be available locally, run:
$ npx prisma generate
For now, running both commands on each schema change isn't too bad. Later on, it might be better to move prisma generate
(or migrate
) into a build step.