From 8b3e8a58297dbb3d417c89e27dbd2ba9faa4cdbb Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Wed, 4 Dec 2024 08:31:44 -0300 Subject: [PATCH] Chore/server prs (#197) * build(deps): bump com.puppycrawl.tools:checkstyle in /server Bumps [com.puppycrawl.tools:checkstyle](https://github.com/checkstyle/checkstyle) from 10.20.1 to 10.20.2. - [Release notes](https://github.com/checkstyle/checkstyle/releases) - [Commits](https://github.com/checkstyle/checkstyle/compare/checkstyle-10.20.1...checkstyle-10.20.2) --- updated-dependencies: - dependency-name: com.puppycrawl.tools:checkstyle dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * build(deps): bump org.springframework.boot:spring-boot-starter-parent Bumps [org.springframework.boot:spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 3.3.5 to 3.3.6. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.3.5...v3.3.6) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * docs: add cloud native compile command to tools * docs: improve tools for backend and scripts --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- server/pom.xml | 4 ++-- tools/check-backend.sh | 25 +++++++++++++++++++++++++ tools/run-create-env.sh | 13 ++++++++++++- tools/tools.md | 8 +++++--- 4 files changed, 44 insertions(+), 6 deletions(-) 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.