From 6d27889efe6df5f6140c67663c51618b85d64518 Mon Sep 17 00:00:00 2001 From: Ada Werefox Date: Wed, 9 Nov 2022 17:22:33 +0000 Subject: [PATCH] I reworked the deploy script. --- deploy.sh | 47 +++++++++++++++------------------ docker-compose.yml | 7 +++-- src/obsl/styles/Home.module.css | 9 ++++--- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/deploy.sh b/deploy.sh index 10e68ec..75362a7 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index e9dd102..f6d7d0c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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"' diff --git a/src/obsl/styles/Home.module.css b/src/obsl/styles/Home.module.css index bd50f42..63b0708 100644 --- a/src/obsl/styles/Home.module.css +++ b/src/obsl/styles/Home.module.css @@ -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;