diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..43b27d2e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,50 @@ +# Git & version control +.git +.gitignore +.gitattributes + +# Build artifacts (very important!) +target/ +build/ +*.jar # unless you COPY it explicitly – but usually not needed +*.war + +# IDE & editor files +.idea/ +.vscode/ +*.iml +*.iws +*.swp +*.swo +.DS_Store + +# Logs, temp, local configs +*.log +logs/ +tmp/ +temp/ +*.tmp +*.bak + +# Maven/Gradle wrapper & cache +.mvn/ +gradle/ +gradlew +gradlew.bat +.m2/ +.gradle/ + +# Docker & compose files (optional – prevents sending them unnecessarily) +Dockerfile* +docker-compose* +*.dockerignore + +# Environment & secrets (critical!) +.env +.env.* +*.secret +application-secrets.yml + +# Tests & coverage +coverage/ +jacoco.exec \ No newline at end of file diff --git a/.gitignore b/.gitignore index 667aaef0..7d039038 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,7 @@ build/ ### VS Code ### .vscode/ + +.env +.env.local +.env.* diff --git a/compose.yaml b/compose.yaml index c47f68ff..a29be3e6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,11 +6,15 @@ services: dockerfile: users_microservice/Dockerfile image: leonard1thecoder/aa-users-microservice:latest environment: - SPRING_PROFILES_ACTIVE: docker - SPRING_REDIS_HOST: redis - SPRING_REDIS_PORT: 6379 + SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-dev} + SPRING_REDIS_HOST: ${REDIS_HOST:-redis} + SPRING_REDIS_PORT: ${REDIS_PORT:-6379} + SUPABASE_URL: ${SUPABASE_URL} # ← pulled from .env + MAIL_USERNAME: ${MAIL_USERNAME} + MAIL_PASSWORD: ${MAIL_PASSWORD} + PORT: ${CONTAINER_PORT:-9098} ports: - - "8080:9098" # Adjust if needed + - "${APP_EXTERNAL_PORT:-8080}:${CONTAINER_PORT:-9098}" # Adjust if needed depends_on: redis: condition: service_healthy # Waits until Redis reports healthy diff --git a/users_microservice/src/main/resources/application-dev.properties b/users_microservice/src/main/resources/application-dev.properties new file mode 100644 index 00000000..b3d4d953 --- /dev/null +++ b/users_microservice/src/main/resources/application-dev.properties @@ -0,0 +1,18 @@ +spring.config.active.on-profile=dev + +spring.sql.unit.mode= always + + +# MySQL Database Configuration +spring.datasource.url=${SUPABASE_URL} + +spring.flyway.clean-disabled=false + +server.port=${PORT} +spring.mail.host=smtp.gmail.com +spring.mail.port=587 +spring.mail.username=${MAIL_USERNAME} +spring.mail.password=${MAIL_PASSWORD} +spring.mail.properties.mail.smtp.auth=true +spring.mail.properties.mail.smtp.starttls.enable=true +spring.docker.compose.enabled=true diff --git a/users_microservice/src/main/resources/application-docker.properties b/users_microservice/src/main/resources/application-docker.properties deleted file mode 100644 index 376596db..00000000 --- a/users_microservice/src/main/resources/application-docker.properties +++ /dev/null @@ -1,9 +0,0 @@ -# Server port (mapped in docker-compose.yml) -server.port=9098 - -# Redis connection (service name from docker-compose.yml) -spring.redis.host=redis -spring.redis.port=6379 - -# Optional: logging level -logging.level.org.springframework=INFO diff --git a/users_microservice/src/main/resources/application-prod.properties b/users_microservice/src/main/resources/application-prod.properties new file mode 100644 index 00000000..bbe0b336 --- /dev/null +++ b/users_microservice/src/main/resources/application-prod.properties @@ -0,0 +1,28 @@ +spring.config.active.on-profile=prod +# MySQL Database Configuration +spring.datasource.url=${SUPABASE_URL} + +spring.flyway.clean-disabled=true +spring.flyway.enabled=true + +logging.level.root=WARN +logging.level.org.springframework=INFO +logging.level.org.hibernate=WARN + + +server.port=${PORT} +spring.mail.host=smtp.gmail.com +spring.mail.port=587 +spring.mail.username=${MAIL_USERNAME} +spring.mail.password=${MAIL_PASSWORD} +spring.mail.properties.mail.smtp.auth=true +spring.mail.properties.mail.smtp.starttls.enable=true +spring.docker.compose.enabled=false + +spring.datasource.hikari.maximum-pool-size=10 +spring.datasource.hikari.minimum-idle=5 +spring.datasource.hikari.idle-timeout=300000 +spring.datasource.hikari.connection-timeout=20000 +spring.datasource.hikari.max-lifetime=1800000 +spring.datasource.hikari.leak-detection-threshold=2000 +spring.datasource.hikari.pool-name=UsersHikariPool diff --git a/users_microservice/src/main/resources/application.properties b/users_microservice/src/main/resources/application.properties index 5cb4a663..1148abac 100644 --- a/users_microservice/src/main/resources/application.properties +++ b/users_microservice/src/main/resources/application.properties @@ -1,14 +1,17 @@ spring.application.name=AA -# MySQL Database Configuration -spring.datasource.url=jdbc:mysql://localhost:3306/aa -spring.datasource.username=root -spring.datasource.password= -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + +spring.docker.compose.file=src/main/resources/compose.yaml +logging.level.org.springframework.boot.docker.compose=DEBUG +spring.docker.compose.lifecycle-management=start_only +spring.threads.virtual.enabled= true + +spring.datasource.driver-class-name=org.postgresql.Driver + + # JPA Configuration spring.jpa.hibernate.ddl-auto=update hibernate.temp.use_jdbc_metadata_defaults=false spring.jpa.show-sql=true spring.jpa.format-sql=true -spring.jpa.open-in-view=false -spring.jpa.properties.hibernate.dialect.storage_engine=innodb +spring.jpa.open-in-view=false \ No newline at end of file