2021-10-06 23:04:38 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -xe
|
|
|
|
|
|
|
|
APP_FOLDER=info
|
2023-11-28 19:30:59 -06:00
|
|
|
CONTAINER_NAME=info-werefox-cafe
|
2021-10-06 23:04:38 -05:00
|
|
|
|
|
|
|
MODE=$1
|
2022-12-05 19:51:43 -06:00
|
|
|
x=$(APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose ps | grep $CONTAINER_NAME | wc -l)
|
|
|
|
|
2023-01-17 12:22:01 -06:00
|
|
|
if [ "$MODE" == "" ] || [ "$MODE" != "build" && "$MODE" != "dev" && "$MODE" != "start" ]; then
|
2022-12-05 19:51:43 -06:00
|
|
|
echo "Please use 'dev', 'build', or 'start' as an argument."
|
|
|
|
exit 1
|
2021-10-06 23:04:38 -05:00
|
|
|
fi
|
|
|
|
|
2022-12-05 19:51:43 -06:00
|
|
|
if [ $x -eq 1 ]; then
|
|
|
|
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose rm -sf
|
|
|
|
fi
|
2021-10-06 23:04:38 -05:00
|
|
|
|
2022-12-05 19:51:43 -06:00
|
|
|
if [ ! -d "$(pwd)/src/$APP_FOLDER" ]; then
|
|
|
|
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose run $CONTAINER_NAME sh -c "npm install --silent create-next-app && \
|
|
|
|
npx create-next-app /usr/src/app/$APP_FOLDER --ts --eslint && \
|
|
|
|
cd $APP_FOLDER && npm install tailwindcss autoprefixer && npx tailwindcss init -p && \
|
|
|
|
cd /usr/src/app && rm -rf node_modules package.json package-lock.json"
|
2021-10-06 23:04:38 -05:00
|
|
|
fi
|
|
|
|
|
2023-01-17 12:22:01 -06:00
|
|
|
|
2022-12-05 19:51:43 -06:00
|
|
|
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose run $CONTAINER_NAME sh -c "cd $APP_FOLDER && npm install --silent"
|
|
|
|
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose run $CONTAINER_NAME sh -c "cd $APP_FOLDER && npx next telemetry disable"
|
2021-10-06 23:04:38 -05:00
|
|
|
|
2023-01-17 12:22:01 -06:00
|
|
|
if [ "$MODE" == "build" ]; then
|
|
|
|
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose run $CONTAINER_NAME sh -c "cd $APP_FOLDER && npm run build"
|
|
|
|
elif [ "$MODE" == "dev" ] || [ "$MODE" == "start" ]; then
|
|
|
|
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose up -d
|
2022-12-05 19:51:43 -06:00
|
|
|
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose logs -f
|
2023-01-17 12:22:01 -06:00
|
|
|
fi
|