I reworked the deploy script.
This commit is contained in:
parent
c134ee865f
commit
6d27889efe
47
deploy.sh
47
deploy.sh
@ -6,33 +6,28 @@ APP_FOLDER=obsl
|
|||||||
CONTAINER_NAME=app
|
CONTAINER_NAME=app
|
||||||
|
|
||||||
MODE=$1
|
MODE=$1
|
||||||
x=$(sudo docker container ls | grep next-js | wc -l)
|
x=$(APP_FOLDER=$APP_FOLDER MODE=$MODE docker compose ps | grep $CONTAINER_NAME | wc -l)
|
||||||
if [ $x -eq 1 ]; then
|
|
||||||
sudo MODE=$MODE docker-compose rm -sf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $MODE == "build" ]; then
|
if [ "$MODE" == "" ]; 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
|
|
||||||
echo "Please use 'dev', 'build', or 'start' as an argument."
|
echo "Please use 'dev', 'build', or 'start' as an argument."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
||||||
|
@ -3,12 +3,11 @@ version: "3"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: werefox-obs-layouts
|
image: node:alpine
|
||||||
container_name: obs-layouts
|
|
||||||
build: .
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/usr/src/app/
|
- ./src:/usr/src/app/
|
||||||
ports:
|
ports:
|
||||||
- "3001:3000"
|
- "3001:3000"
|
||||||
user: "1000:1000"
|
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"'
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
.container {
|
.container {
|
||||||
padding: 0 2rem;
|
padding: 0 2rem;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
min-height: 100vh;
|
|
||||||
padding: 4rem 0;
|
padding: 4rem 0;
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
flex-wrap: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
|
||||||
padding: 2rem 0;
|
padding: 2rem 0;
|
||||||
border-top: 1px solid #eaeaea;
|
border-top: 1px solid #eaeaea;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
Loading…
Reference in New Issue
Block a user