I reworked the deploy script.

This commit is contained in:
Ada Werefox 2022-11-09 17:22:33 +00:00
parent c134ee865f
commit 6d27889efe
3 changed files with 30 additions and 33 deletions

View File

@ -6,33 +6,28 @@ APP_FOLDER=obsl
CONTAINER_NAME=app
MODE=$1
x=$(sudo docker container ls | grep next-js | wc -l)
if [ $x -eq 1 ]; then
sudo MODE=$MODE docker-compose rm -sf
fi
x=$(APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose ps | grep $CONTAINER_NAME | wc -l)
if [ $MODE == "build" ]; then
sudo MODE=$MODE docker-compose build --no-cache --pull
else
sudo MODE=$MODE docker-compose build
fi
if [ ! -d "$(pwd)/src/$APP_FOLDER" ]; then
sudo MODE=$MODE docker-compose run $CONTAINER_NAME npx create-next-app /usr/src/app/$APP_FOLDER --ts --eslint
sudo MODE=$MODE docker-compose run $CONTAINER_NAME bash -c "cd $APP_FOLDER && npm install tailwindcss autoprefixer"
sudo MODE=$MODE docker-compose run $CONTAINER_NAME bash -c "cd $APP_FOLDER && npx tailwindcss init -p"
sudo chown -R $USER:$USER ./src
fi
sudo MODE=$MODE docker-compose run $CONTAINER_NAME bash -c "cd $APP_FOLDER && npm install --silent"
sudo MODE=$MODE docker-compose run $CONTAINER_NAME bash -c "cd $APP_FOLDER && npx next telemetry disable"
if [ $MODE == "dev" ] || [ $MODE == "start" ]; then
sudo MODE=$MODE docker-compose up --build --force-recreate --remove-orphans -d
sudo MODE=$MODE docker-compose logs -f
elif [ $MODE == "build" ]; then
sudo MODE=$MODE docker-compose run $CONTAINER_NAME bash -c "cd $APP_FOLDER && npm run build"
else
if [ "$MODE" == "" ]; then
echo "Please use 'dev', 'build', or 'start' as an argument."
exit 1
fi
if [ $x -eq 1 ]; then
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose rm -sf
fi
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"
fi
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"
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose up -d
if [ "$MODE" == "dev" ] || [ "$MODE" == "start" ]; then
APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose logs -f
fi

View File

@ -3,12 +3,11 @@ version: "3"
services:
app:
image: werefox-obs-layouts
container_name: obs-layouts
build: .
image: node:alpine
volumes:
- ./src:/usr/src/app/
ports:
- "3001:3000"
user: "1000:1000"
command: bash -c "cd obsl && npm run $MODE"
working_dir: "/usr/src/app"
command: 'sh -c "cd $APP_FOLDER && npm run $MODE"'

View File

@ -1,20 +1,23 @@
.container {
padding: 0 2rem;
min-height: 100vh;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
}
.main {
min-height: 100vh;
padding: 4rem 0;
flex: 1;
display: flex;
flex-grow: 1;
flex-direction: column;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
}
.footer {
display: flex;
flex: 1;
padding: 2rem 0;
border-top: 1px solid #eaeaea;
justify-content: center;