Created
November 14, 2020 19:03
-
-
Save evanhsu/7642ebde1486767e596446bf4d524903 to your computer and use it in GitHub Desktop.
Run yarn commands inside docker-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
root_path=$( cd "$(dirname $(dirname "${BASH_SOURCE[0]}"))" ; pwd -P ) | |
# Check to see if the node_modules folder exists in the 'web' project | |
if [ ! -d "$root_path/web/node_modules" ]; then | |
echo "No '/web/node_modules' folder found. Running 'yarn' in the web project..."; | |
# Just go ahead and run yarn automatically... | |
cd $root_path/web | |
nvm use && yarn | |
fi | |
# Check to see if the node_modules folder exists in the 'api' project | |
if [ ! -d "$root_path/api/node_modules" ]; then | |
echo "No '/api/node_modules' folder found. Running 'yarn' in the api project..."; | |
# Just go ahead and run yarn automatically... | |
cd $root_path/api | |
nvm use && yarn | |
fi | |
cd $root_path | |
# All arguments passed to this script will be set in the DC_YARN_COMMAND environment variable. | |
# Docker-compose will interpret this var as the command to be passed to 'yarn' | |
# This docker-compose command layers two docker-compose.yml files on top of each other | |
DC_YARN_COMMAND="$@" docker-compose --env-file=.env.example -f docker-compose.yml -f docker-compose.dev.yml up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.7" | |
services: | |
web: | |
ports: | |
- "1234:1234" # parcel web server | |
- "1235:1235" # parcel hmr server | |
- "6006:6006" # storybook | |
volumes: | |
- ./web/:/usr/src/ | |
entrypoint: ["yarn", "${DC_YARN_COMMAND:?err}"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment