How to run docker-compose entrypoint configuration option with multiple or multiline bash commands
commands:
yarn install
yarn build
sleep infinity
I figured out how!
Steps:
docker-compose.yml
, say for service: gvhservice
, add below lines of code gvhservice:
entrypoint:
- "/bin/sh"
- -ecx
- |
yarn install
yarn build
sleep infinity
entrypoint.sh
Where in entrypoint.sh
, add below lines of code:
#!/bin/sh
set -ex
yarn install
yarn build
sleep infinity
where in docker-compose.yml
, add below lines of code:
gvhservice:
entrypoint: entrypoint.sh
ENTRYPOINT
instruction within the container and command
instruction and operator |
configuration option in docker-compose.yml
(suitable for a variable number of commands to be passed during runtime)build you container with instruction:
COPY entrypoint.sh .
and
where contents of entrypoint.sh
is:
#!/bin/sh
set -ex
exec "$@"
where in docker-compose.yml
, add below lines of code
gvhservice:
entrypoint: entrypoint.sh
command:
- "/bin/sh"
- -ecx
- |
yarn install
yarn build
sleep infinity