Reputation: 2074
I'm pretty new with docker, but trying to get docker-compose handling my local dev environment. Essentially when I run docker-compose up
it should have my api running on port 3000:3000
This is my current docker-compose.yml
file:
version: "3"
services:
api:
image: node:9
ports:
- 127.0.0.1:3000:3000
working_dir: /api
volumes:
- ./:/api
command: bash -c 'yarn && cd api && yarn dev'
mongo:
image: mongo:3.4
ports:
- 127.0.0.1:27017:27017
volumes:
- ./db:/data/db
minio:
image: minio/minio
ports:
- 9000:9000
environment:
- MINIO_ACCESS_KEY=miniokey
- MINIO_SECRET_KEY=miniosecret
volumes:
- ./minio:/data
command: ["server", "/data"]
createbuckets:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
while ! /usr/bin/nc minio 9000; do sleep 2s; done;
/usr/bin/mc config host add myminio http://minio:9000 miniokey miniosecret;
/usr/bin/mc mb myminio/vividaura;
/usr/bin/mc policy download myminio/vividaura;
/usr/bin/mc mb myminio/vividaura-test;
/usr/bin/mc policy download myminio/vividaura-test;
exit 0;
"
nats:
image: nats:1.1.0-linux
ports:
- 127.0.0.1:4222:4222
- 127.0.0.1:8222:8222
The thing is, I'm using yarn's workspace feature. So I need to run yarn in the root directory then run yarn inside /api
This is my folder structure:
> /api
> /image-compose
> /src
> docker-compose.yml
> package.json
Upvotes: 2
Views: 904
Reputation: 2074
I got it working. Had issues with the ports. This is my updated docker-compose.yml
file:
version: "3"
services:
web:
image: node:9
ports:
- 3000:3000
working_dir: /app
volumes:
- ./:/app
command: bash -c 'yarn && cd src && yarn dev'
depends_on:
- api
api:
image: node:9
ports:
- 3001:3001
working_dir: /api
volumes:
- ./:/api
command: bash -c 'yarn && cd api && yarn dev'
depends_on:
- mongo
- nats
mongo:
image: mongo:3.4
ports:
- 127.0.0.1:27017:27017
volumes:
- ./db:/data/db
minio:
image: minio/minio
ports:
- 9000:9000
environment:
- MINIO_ACCESS_KEY=miniokey
- MINIO_SECRET_KEY=miniosecret
volumes:
- ./minio:/data
command: ["server", "/data"]
createbuckets:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
while ! /usr/bin/nc minio 9000; do sleep 2s; done;
/usr/bin/mc config host add myminio http://minio:9000 miniokey miniosecret;
/usr/bin/mc mb myminio/vividaura;
/usr/bin/mc policy download myminio/vividaura;
/usr/bin/mc mb myminio/vividaura-test;
/usr/bin/mc policy download myminio/vividaura-test;
exit 0;
"
nats:
image: nats:1.1.0-linux
ports:
- 127.0.0.1:4222:4222
- 127.0.0.1:8222:8222
Upvotes: 2