Docker Compose
Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to use a YAML file to configure your application's services, networks, and volumes, and then spin up all the containers required to run your application with a single command.
Add compose/docker-compose.yml:
services:
lr-webchat-rs:
build:
context: ../
dockerfile: Dockerfile
ports:
- 4000:4000
environment:
- PORT=4000
lr-webchat-react:
build:
context: ../../lr_webchat
dockerfile: Dockerfile
ports:
- 3000:3000
depends_on:
lr-webchat-rs:
condition: service_started
Run it:
cd compose
docker compose up
You should see something like this:
[+] Running 2/2
✔ Container compose-lr-webchat-rs-1 Created 0.1s
✔ Container compose-lr-webchat-react-1 Recreated 0.1s
Attaching to lr-webchat-react-1, lr-webchat-rs-1
lr-webchat-rs-1 | Chat server serving at localhost:4000
lr-webchat-react-1 | INFO Accepting connections at http://localhost:3000
...
Now, if you visit your page at http://localhost:3000, you should be able to see the UI of the chat app.
Your web chat app works like a charm! 📢