My docker-compose.yml
looks something like this
version: '3.8'
services:
database:
image: "postgres:10.16"
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=pg_database
volumes:
- database-data:/var/lib/postgresql/data/
ports:
- "35432:5432"
api:
build: ../../api
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=user
- POSTGRES_DB=pg_database
- POSTGRES_HOST=database
- POSTGRES_PORT=35432
ports:
- "3030:3030"
depends_on:
- "database"
migrations:
image: "node:14.17.5-alpine3.14"
volumes:
- "../migrations/scripts:/tmp"
- "../../api:/tmp/api"
links:
- database
command: "sh /tmp/migration_test.sh postgresql://user:password@host.docker.internal:35432/pg_database"
depends_on:
- "api"
- "database"
volumes:
database-data:
This works if I'm running one shell script in migration
services. However, I want to be able to run 2 shell scripts. One right after the other. Not at the same time. Something like this
migrations:
image: "node:14.17.5-alpine3.14"
volumes:
- "../migrations/scripts:/tmp"
- "../../api:/tmp/api"
links:
- database
command: >
"sh /tmp/migration_test.sh postgresql://user:password@host.docker.internal:35432/pg_database" &&
"sh /tmp/migration_test2.sh postgresql://user:password@host.docker.internal:35432/pg_database"
depends_on:
- "api"
- "database"
I'm not getting the right syntax to get this to work. I've tried different ways and can't figure it out. Does anyone have any suggestions? Is it possible to run two shell scripts one after the other?