Do I have to first have to clone the wait-for-it repo and edit the parts of the wait-for-it.sh file?
https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh
I'm trying to make my main file fire after 5 seconds after my customer service connects and run its server. (Or whenever customer service connects server properly).
I am aware that in the Dockerfile, we would need to add these commands to it (copying file into workdir, and run the shell script as an executable.)
...
COPY wait-for-it.sh .
RUN chmod +x /wait-for-it.sh
...
Here's my current Docker-Compose file
version: '3'
services:
books:
build: './books'
container_name: "horus-books"
ports:
- "30043:30043"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
customers:
depends_on:
- books
build: './customers'
container_name: "horus-customers"
ports:
- "6000:6000"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
main:
depends_on:
- customers
build: './main'
container_name: "horus-main"
ports:
- "4555:4555"
command: ["./wait-for-it.sh", "customers:6000", "--", "node", "main.js"]
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
Main Service Dockerfile
FROM node:12.14.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . /usr/src/app
COPY wait-for-it.sh .
RUN chmod +x /wait-for-it.sh
RUN npm install
EXPOSE 4555
CMD ["node", "main.js"]