-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·51 lines (42 loc) · 1.98 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# Load environment variables
cp .env.sample .env
. ./.env
SAMPLE_DATA_ARCHIVE_LOCATION=/tmp/sampledata.archive
# Check local environment
echo "> Checking local environment..."
if [ ! -x "$(command -v docker)" ]; then
echo "> Docker is not installed! Please install Docker."
exit 1
elif ! docker compose version > /dev/null 2>&1; then
echo "> Docker Compose is not installed! Please install Docker Compose."
exit 1
elif [ ! -x "$(command -v curl)" ]; then
echo "> cURL is not installed! Please install cURL."
exit 1
elif [ -z $MONGO_CONTAINER_NAME ]; then
echo "> MONGO_CONTAINER_NAME is not set! Please set MONGO_CONTAINER_NAME."
exit 1
elif [ -z $APP_HOST_PORT ]; then
echo "> APP_HOST_PORT is not set! Please set APP_HOST_PORT."
exit 1
fi
echo "> Local environment is ready!"
# Docker Compose up
echo "> Running Docker Compose..."
docker compose up --build --detach
# Announce that FastLazyBee is up and running
echo "> FastLazyBee is up and running! Please wait for initial data to be loaded into the database..."
# Download the official MongoDB sample data archive (dump) from AWS S3
if [ ! -f $SAMPLE_DATA_ARCHIVE_LOCATION ]; then
echo "> Downloading the official MongoDB sample data archive (dump) from AWS S3..."
curl https://atlas-education.s3.amazonaws.com/sampledata.archive > $SAMPLE_DATA_ARCHIVE_LOCATION
echo "> Sample data archive downloaded successfully!"
fi
# Copy the sample data archive to the MongoDB container
docker cp $SAMPLE_DATA_ARCHIVE_LOCATION $MONGO_CONTAINER_NAME:/$SAMPLE_DATA_ARCHIVE_LOCATION
# Restore the sample data archive in the MongoDB container
docker exec $MONGO_CONTAINER_NAME mongorestore --archive=/$SAMPLE_DATA_ARCHIVE_LOCATION --drop
# Announce that the initial data has been loaded successfully and provide the URL to access the FastLazyBee app
echo "> Initial data loaded successfully!"
echo "> You can now run the FastLazyBee app by opening http://localhost:$APP_HOST_PORT/docs in your browser."