-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c44370
commit 9fbf796
Showing
4 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# .gitignore | ||
|
||
*.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Composes DynamoDB Local, the DynamoDB Admin UI, and Redis | ||
version: '3.7' | ||
|
||
services: | ||
dynamodb: | ||
image: amazon/dynamodb-local | ||
ports: | ||
- "8000:8000" | ||
|
||
dynamodb-admin: | ||
image: aaronshaf/dynamodb-admin | ||
ports: | ||
- "8001:8001" | ||
environment: | ||
- DYNAMO_ENDPOINT=http://dynamodb:8000 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/sh | ||
# Starts the databases, frontend and backend. | ||
|
||
set -e | ||
|
||
cur_dir=$(realpath $(dirname $0)) | ||
root_dir=$(realpath $(dirname $cur_dir)) | ||
|
||
docker_log=${cur_dir}/docker.log | ||
backend_log=${cur_dir}/backend.log | ||
frontend_log=${cur_dir}/frontend.log | ||
|
||
# Define cleanup function | ||
cleanup() { | ||
echo "Stopping databases..." | ||
docker-compose -f ${cur_dir}/docker-compose.yml down | ||
echo "Killing FastAPI..." | ||
kill $backend_pid || true | ||
echo "Killing React..." | ||
kill $frontend_pid || true | ||
echo "Waiting for services to stop..." | ||
wait $docker_compose_pid | ||
wait $backend_pid | ||
wait $frontend_pid | ||
echo "Services stopped." | ||
} | ||
|
||
# Set trap for cleanup on exit | ||
trap cleanup EXIT | ||
|
||
# Starts docker and gets the pid | ||
docker-compose -f ${cur_dir}/docker-compose.yml up > $docker_log 2>&1 & | ||
docker_compose_pid=$! | ||
|
||
# Starts FastAPI and gets the pid | ||
fastapi dev ${root_dir}/linguaphoto/main.py --port 8080 > $backend_log 2>&1 & | ||
backend_pid=$! | ||
|
||
# Starts React and gets the pid | ||
cd ${root_dir}/frontend | ||
npm start > $frontend_log 2>&1 & | ||
frontend_pid=$! | ||
|
||
# Wait for user to press enter | ||
echo "=====================================" | ||
echo "Docker, FastAPI and React are running" | ||
echo " Visit http://localhost:3000 " | ||
echo "=====================================" | ||
|
||
read -p "Press enter to stop the services" | ||
|
||
# Exits | ||
exit 0 |