diff --git a/server/pom.xml b/server/pom.xml index 7e940d6..90ebfdd 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.5 + 3.3.6 @@ -416,7 +416,7 @@ com.puppycrawl.tools checkstyle - 10.20.1 + 10.20.2 diff --git a/tools/check-backend.sh b/tools/check-backend.sh index e2d240e..fc19c0c 100755 --- a/tools/check-backend.sh +++ b/tools/check-backend.sh @@ -1,3 +1,28 @@ #!/bin/bash +DOCKER_IMG="server:nightly" + +docker image inspect $DOCKER_IMG --format="ignore me" +if [ $? -eq 1 ]; then + echo "Image not found locally! Building it..." + + if [ ! -f "server/.env" ]; then + echo "No env file found for back-end. Creating one for you.." + bash tools/run-create-env.sh "back" + else + echo "Env file in place. Moving on.." + fi + + echo "Getting env vars and making them visible" + cd server/ + export $(cat .env | xargs) + echo "Done!" + + cd .. + docker build --file server/Dockerfile.dev --tag server:nightly . +else + echo "Image found! Let's keep going." +fi + + docker run -it --rm --name server -e CHECK="TRUE" -v ./server:/app server:nightly diff --git a/tools/run-create-env.sh b/tools/run-create-env.sh index b798a28..3ccca39 100644 --- a/tools/run-create-env.sh +++ b/tools/run-create-env.sh @@ -3,6 +3,11 @@ TARGET="$1" if [ "$TARGET" == "back" ]; then + if [ -f "server/.env" ]; then + echo "Env file in place. Leaving..." + exit 0 + fi + echo "Creating basic env file for database and back-end" cd server @@ -13,7 +18,12 @@ if [ "$TARGET" == "back" ]; then echo "POSTGRES_PORT=5432" >> .env echo "SERVER_SERVLET_CONTEXT_PATH=/" >> .env echo "CORS_ALLOWED_ORIGINS=http://localhost:5000" >> .env -if [ "$TARGET" == "front" ]; then +elif [ "$TARGET" == "front" ]; then + if [ -f "client/.env" ]; then + echo "Env file in place. Leaving..." + exit 0 + fi + echo "Creating basic env file for the front-end app" cd client @@ -22,4 +32,5 @@ if [ "$TARGET" == "front" ]; then else echo "Wrong parameter..." fi + echo "Done!" diff --git a/tools/tools.md b/tools/tools.md index e4df5df..74359da 100644 --- a/tools/tools.md +++ b/tools/tools.md @@ -46,16 +46,16 @@ Here are a few steps: ```bash export SERVER_IP= -export SERVER_ADDRRESS= +export SERVER_ADDRESS= npm ci --ignore-scripts --no-update-notifier --omit=dev -export VITE_BACKEND_SERVER=$SERVER_ADDRRESS/server +export VITE_BACKEND_SERVER=$SERVER_ADDRESS/server npm run build zip -r "client_$VERSION.zip" dist/ scp "client_$VERSION.zip" root@$SERVER_IP:/root/ ``` -## Runing with Docker +## Running with Docker **DB:** @@ -86,6 +86,8 @@ docker run -d --rm \ ghcr.io/ricardo-campos-org/react-typescript-todolist/server: ``` +Build Cloud Native: `./mvnw -B package -Pnative -DskipTests` + **Client:** The frontend app will run on Nginx.