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-node:
build:
context: ../
dockerfile: Dockerfile
ports:
- 4000:4000
environment:
- PORT=4000
lr-webchat-react:
build:
context: ../../lr_webchat
dockerfile: Dockerfile
ports:
- 3000:3000
environment:
- CHAT_SERVER_URL="http://lr-webchat-node:4000"
depends_on:
lr-webchat-node:
condition: service_started
Run it:
cd compose
docker compose up
You should see something like this:
[+] Running 2/1
✔ Container compose-lr-webchat-node-1 Created 0.1s
✔ Container compose-lr-webchat-react-1 Created 0.0s
Attaching to lr-webchat-node-1, lr-webchat-react-1
lr-webchat-node-1 | Chat Server listening on port 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! 📢