Skip to content

Commit

Permalink
Merge pull request #33 from shreypandey/refactor_docker_compose
Browse files Browse the repository at this point in the history
Added docker compose for stage and updated run.sh
  • Loading branch information
sameersegal authored May 22, 2024
2 parents 04292cb + 224724d commit e83109f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
19 changes: 19 additions & 0 deletions docker-compose.stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
api:
image: opennyaiin/jugalbandi-manager:api-1.0.0
language:
image: opennyaiin/jugalbandi-manager:language-1.0.0
flow:
image: opennyaiin/jugalbandi-manager:flow-1.0.0
indexer:
build:
context: . # Root directory of the project
dockerfile: ./indexer/Dockerfile
retriever:
image: opennyaiin/jugalbandi-manager:retriever-1.0.0
channel:
image: opennyaiin/jugalbandi-manager:channel-1.0.0
frontend:
build:
context: . # Root directory of the project
dockerfile: ./frontend/Dockerfile
35 changes: 30 additions & 5 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@
env_file=".env-dev"

# Process command-line arguments
while getopts 'e:' flag; do
while getopts 'e:-:' flag; do
case "${flag}" in
e) env_file="${OPTARG}" ;;
-) case "${OPTARG}" in
stage)
stage=true
;;
*)
echo "Unknown option --${OPTARG}" >&2
exit 1
;;
esac
;;
*) echo "Usage: $0 [-e env_file] [service1 service2 ...]"
exit 1 ;;
esac
Expand All @@ -33,7 +43,22 @@ else
echo "Setting Kakfa & Postgres host by docker-compose service name: kafka, postgres"
fi

docker compose build $@ --build-arg VITE_SERVER_HOST=$JB_API_SERVER_HOST

# Run docker-compose with the specified environment file and services
docker compose --env-file "$env_file" up $@
if [ -n "$stage" ]; then
for arg in "$@"
do
if [[ "$arg" == "frontend" ]]; then
# Build the frontend with the specified environment file
docker compose build $@ --build-arg VITE_SERVER_HOST=$JB_API_SERVER_HOST
break
fi
done
# Run docker-compose with the specified environment file and services
echo "Running docker-compose with existing images"
docker compose --env-file "$env_file" -f "docker-compose.yml" -f docker-compose.stage.yml up $@
else
echo "Building and running docker-compose"
# Build the services with the specified environment file
docker compose build $@ --build-arg VITE_SERVER_HOST=$JB_API_SERVER_HOST
# Run docker-compose with the specified environment file and services
docker compose --env-file "$env_file" up $@
fi

0 comments on commit e83109f

Please sign in to comment.