This project was orgininally setup as independent pieces. There were 2 parts:
- a UI written in Vue, deployed to Vercel
- an API server written in Node, deployed to Heroku
The original idea came from an Egghead course i took. That course built a UI in React with a backend in Firebase. I wrote my own server to replace Firebase, built with Node and Websockets, just to explore how this all worked. The server part was called fire-notes and that part is in the api folder of this repo. I later rewrote the UI while exploring Vue and that was called git-notes. That UI now lives in the app folder of this repo. To simplify things, the Websocket and server connections aren't encrypted, not a big deal since they only run inside this container and it's not designed to be deployed anywhere.
Since the Free tier of Heroku is going away in November of 2022, i decided to repackage this project as a Docker container. When it's running locally, it exposes the following:
- localhost:3000 - the Vue app
- localhost:8082 - websocket server
- localhost:8182 - api server (REST)
To run this multi-part app:
docker-compose build
docker-compose up
➜ proto-notes-dkr git:(main) ✗ docker-compose up
[+] Running 3/2
⠿ Network proto-notes-dkr_backbone Created 0.0s
⠿ Container proto-notes-dkr-api-1 Created 0.0s
⠿ Container proto-notes-dkr-app-1 Created 0.0s
Attaching to proto-notes-dkr-api-1, proto-notes-dkr-app-1
proto-notes-dkr-api-1 | yarn run v1.22.19
proto-notes-dkr-api-1 | $ yarn; node app.mjs
proto-notes-dkr-api-1 | [1/4] Resolving packages...
proto-notes-dkr-app-1 | yarn run v1.22.19
proto-notes-dkr-app-1 | $ yarn; vite build; vite preview --host 0.0.0.0
proto-notes-dkr-api-1 | success Already up-to-date.
proto-notes-dkr-api-1 | -- Notes Server listening on port 8182
proto-notes-dkr-api-1 | -- Websocket Server created on port 8082
proto-notes-dkr-api-1 | -- http://localhost:8182
proto-notes-dkr-app-1 | [1/4] Resolving packages...
proto-notes-dkr-app-1 | [2/4] Fetching packages...
proto-notes-dkr-app-1 | [3/4] Linking dependencies...
proto-notes-dkr-app-1 | [4/4] Building fresh packages...
proto-notes-dkr-app-1 | vite v3.1.3 building for production...
proto-notes-dkr-app-1 | transforming...
proto-notes-dkr-app-1 | ✓ 101 modules transformed.
proto-notes-dkr-app-1 | rendering chunks...
proto-notes-dkr-app-1 | dist/assets/favicon.db74ab0b.ico 4.19 KiB
proto-notes-dkr-app-1 | dist/index.html 1.37 KiB
proto-notes-dkr-app-1 | dist/assets/index.4a29606e.css 1.24 KiB / gzip: 0.52 KiB
proto-notes-dkr-app-1 | dist/assets/index.3fed08c7.js 92.85 KiB / gzip: 35.48 KiB
proto-notes-dkr-app-1 | ➜ Local: http://localhost:3000/
proto-notes-dkr-app-1 | ➜ Network: http://172.18.0.3:3000/
If you prefer, there are yarn commands to handle all of this:
yarn build
- docker-compose buildyarn start
- docker-compose upyarn stop
- docker-compose down
These scripts are just a shortcuts to running docker-compose
.
You will notice that we're not installing any npm packages locally in order to build and run this app suite. All of that is handled by Docker...
- Richard Hess
- https://eswat2.github.io