Folder structure:
#root
|- deployment
| |- start-dev.sh
| |- docker-compose.yml
| |- // other files including app.Dockerfile and anything else I need
|- // everything else
Initial start-dev.sh
#!/bin/sh
docker-compose -p my-container up -d
docker-compose -p my-container exec app bash
Working state
In VS Code (opened as WSL2 remote) integrated terminal I would type
cd deployment
./start-dev.sh
and deployment is successful.
If instead, I tried just deployment/start-dev.sh
it fails, since there's no docker-compose.yml in the current directory.
Desire
I want
deployment/start-dev.sh
to work.
Non-solution
The following fails since dirname
is not available in my case.
#!/bin/sh
BASEDIR=$(dirname $0)
docker-compose -f "${BASEDIR}/docker-compose.yml" -p my-container up -d
docker-compose -f "${BASEDIR}/docker-compose.yml" -p my-container exec app bash
Solution 1 for start-dev.sh
#!/bin/bash
BASEDIR=$(dirname $0)
docker-compose -f "${BASEDIR}/docker-compose.yml" -p my-container up -d
docker-compose -f "${BASEDIR}/docker-compose.yml" -p my-container exec app bash
Question
How do I convert Solution 1 to be a sh
script instead of bash
, if dirname
is not available in sh
?