Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .azure/azure-mysql-config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Azure App Service Configuration for ZenTarea
# This file can be used with Azure CLI for deployment

# Resource Group Configuration
RESOURCE_GROUP=zentarea-rg
LOCATION=eastus

# App Service Plan Configuration
APP_SERVICE_PLAN=zentarea-plan
SKU=B1

# Web App Configuration
WEB_APP_NAME=zentarea-app
RUNTIME="JAVA|17-java17"

# Database Configuration
MYSQL_SERVER_NAME=zentarea-mysql-server
MYSQL_ADMIN_USER=zentareaadmin
MYSQL_DATABASE_NAME=zentareadb

# Environment Variables for App Service
SPRING_PROFILES_ACTIVE=azure-mysql
AZURE_MYSQL_URL=jdbc:mysql://${MYSQL_SERVER_NAME}.mysql.database.azure.com:3306/${MYSQL_DATABASE_NAME}?useSSL=true&requireSSL=false&serverTimezone=UTC
AZURE_MYSQL_USERNAME=${MYSQL_ADMIN_USER}@${MYSQL_SERVER_NAME}
63 changes: 63 additions & 0 deletions .azure/deploy-mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
# Azure MySQL Deployment Script for ZenTarea

# Load configuration
source .azure/azure-mysql-config.env

echo "Deploying ZenTarea to Azure with MySQL..."

# Create Resource Group
az group create --name $RESOURCE_GROUP --location $LOCATION

# Create MySQL Server
az mysql flexible-server create \
--resource-group $RESOURCE_GROUP \
--name $MYSQL_SERVER_NAME \
--location $LOCATION \
--admin-user $MYSQL_ADMIN_USER \
--admin-password $MYSQL_ADMIN_PASSWORD \
--sku-name Standard_B1ms \
--tier Burstable \
--public-access 0.0.0.0 \
--storage-size 20 \
--version 8.0.21

# Create Database
az mysql flexible-server db create \
--resource-group $RESOURCE_GROUP \
--server-name $MYSQL_SERVER_NAME \
--database-name $MYSQL_DATABASE_NAME

# Create App Service Plan
az appservice plan create \
--name $APP_SERVICE_PLAN \
--resource-group $RESOURCE_GROUP \
--location $LOCATION \
--sku $SKU \
--is-linux

# Create Web App
az webapp create \
--name $WEB_APP_NAME \
--resource-group $RESOURCE_GROUP \
--plan $APP_SERVICE_PLAN \
--runtime $RUNTIME

# Configure App Settings
az webapp config appsettings set \
--name $WEB_APP_NAME \
--resource-group $RESOURCE_GROUP \
--settings \
SPRING_PROFILES_ACTIVE=$SPRING_PROFILES_ACTIVE \
AZURE_MYSQL_URL=$AZURE_MYSQL_URL \
AZURE_MYSQL_USERNAME=$AZURE_MYSQL_USERNAME \
AZURE_MYSQL_PASSWORD=$MYSQL_ADMIN_PASSWORD

# Deploy the JAR file (assumes it's been built)
az webapp deploy \
--name $WEB_APP_NAME \
--resource-group $RESOURCE_GROUP \
--src-path build/libs/ZenTarea-0.0.1-SNAPSHOT.jar \
--type jar

echo "Deployment completed! Your app should be available at: https://$WEB_APP_NAME.azurewebsites.net"
17 changes: 17 additions & 0 deletions .env.azure-mysql.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Azure MySQL Environment Configuration
# Copy this to .env and modify the values for your Azure deployment

# Spring Profile
SPRING_PROFILES_ACTIVE=azure-mysql

# Azure MySQL Database Configuration
AZURE_MYSQL_URL=jdbc:mysql://your-server.mysql.database.azure.com:3306/zentareadb?useSSL=true&requireSSL=false&serverTimezone=UTC
AZURE_MYSQL_USERNAME=your-username@your-server
AZURE_MYSQL_PASSWORD=your-password

# Optional: Azure Application Insights
APPINSIGHTS_INSTRUMENTATIONKEY=your-insights-key

# Optional: Logging Level
LOGGING_LEVEL_ROOT=INFO
LOGGING_LEVEL_SPRING_PRACTICE_ZENTAREA=DEBUG
17 changes: 17 additions & 0 deletions .env.mongodb.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# MongoDB Environment Configuration
# Copy this to .env and modify the values for your MongoDB deployment

# Spring Profile
SPRING_PROFILES_ACTIVE=mongodb

# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/zentarea
MONGODB_DATABASE=zentarea

# For MongoDB Atlas (Cloud)
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/zentarea?retryWrites=true&w=majority

# Optional: Logging Level
LOGGING_LEVEL_ROOT=INFO
LOGGING_LEVEL_SPRING_PRACTICE_ZENTAREA=DEBUG
LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_DATA_MONGODB=DEBUG
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ out/

### VS Code ###
.vscode/

### Environment Files ###
.env
.env.*
!.env.*.example

### Azure ###
.azure/azure-config.local
210 changes: 210 additions & 0 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# ZenTarea Platform Hosting Guide

This document describes how to deploy ZenTarea on different platforms with various database backends.

## Supported Platforms

### SQL Databases
- [x] **Azure MSSQL** - Completed (Issue #14)
- [x] **Azure MySQL** - Implemented (Issue #15)

### NoSQL Databases
- [x] **MongoDB** - Implemented (Issue #16)

## Deployment Options

### 1. Azure MySQL Deployment

#### Prerequisites
- Azure CLI installed and configured
- Java 17 or higher
- Gradle

#### Configuration
The application uses the `azure-mysql` profile for Azure MySQL deployment.

**Environment Variables:**
```bash
SPRING_PROFILES_ACTIVE=azure-mysql
AZURE_MYSQL_URL=jdbc:mysql://your-server.mysql.database.azure.com:3306/zentareadb
AZURE_MYSQL_USERNAME=your-username
AZURE_MYSQL_PASSWORD=your-password
```

#### Quick Deployment
```bash
# Build the application
./gradlew build

# Configure your environment (see .azure/azure-mysql-config.env)
export MYSQL_ADMIN_PASSWORD=your-password

# Deploy to Azure
./.azure/deploy-mysql.sh
```

#### Manual Azure Setup
```bash
# Create resource group
az group create --name zentarea-rg --location eastus

# Create MySQL server
az mysql flexible-server create \
--resource-group zentarea-rg \
--name zentarea-mysql-server \
--admin-user zentareaadmin \
--admin-password YOUR_PASSWORD

# Create web app
az webapp create \
--name zentarea-app \
--resource-group zentarea-rg \
--plan zentarea-plan \
--runtime "JAVA|17-java17"
```

### 2. MongoDB Deployment

#### Local Development with Docker
```bash
# Start MongoDB and the application
docker-compose -f docker-compose-mongodb.yml up
```

#### Configuration
The application uses the `mongodb` profile for MongoDB deployment.

**Environment Variables:**
```bash
SPRING_PROFILES_ACTIVE=mongodb
MONGODB_URI=mongodb://localhost:27017/zentarea
MONGODB_DATABASE=zentarea
```

#### Cloud MongoDB (Atlas)
1. Create a MongoDB Atlas cluster
2. Get your connection string
3. Set environment variables:
```bash
export MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/zentarea
export SPRING_PROFILES_ACTIVE=mongodb
```

### 3. Local MySQL Development

#### Using Docker Compose
```bash
# Start MySQL and the application
docker-compose -f docker-compose-mysql.yml up
```

#### Manual Setup
```bash
# Start MySQL locally and set profile
export SPRING_PROFILES_ACTIVE=default
./gradlew bootRun
```

## Application Profiles

### Default Profile
- Uses local MySQL database
- Configuration in `application.properties`

### Azure MySQL Profile
- Uses Azure MySQL Flexible Server
- Configuration in `application-azure-mysql.properties`
- Optimized connection pooling for cloud deployment

### MongoDB Profile
- Uses MongoDB as the primary database
- Configuration in `application-mongodb.properties`
- Disables JPA/Hibernate auto-configuration

## Testing

### Run Tests
```bash
./gradlew test
```

Tests use H2 in-memory database for consistency across environments.

### Profile-Specific Testing
```bash
# Test with specific profile
./gradlew test -Dspring.profiles.active=azure-mysql
```

## Environment Configuration Files

- `application.properties` - Default configuration (local MySQL)
- `application-azure-mysql.properties` - Azure MySQL configuration
- `application-mongodb.properties` - MongoDB configuration
- `application-test.properties` - Test configuration (H2)

## Docker Support

### Building Docker Image
```bash
./gradlew build
docker build -t zentarea:latest .
```

### Available Docker Compose Files
- `docker-compose-mysql.yml` - MySQL + Application
- `docker-compose-mongodb.yml` - MongoDB + Application

## Security Considerations

- Always use environment variables for sensitive configuration
- Enable SSL/TLS for production databases
- Use Azure Key Vault for production secrets
- Configure firewall rules for database access

## Monitoring and Logging

- Application logs are configured in `application-{profile}.properties`
- Use Azure Application Insights for production monitoring
- Database connection health checks are included

## Troubleshooting

### Common Issues

1. **Java Version Mismatch**
- Ensure Java 17 is installed
- Check `java -version`

2. **Database Connection Issues**
- Verify connection strings
- Check firewall settings
- Validate credentials

3. **Profile Not Loading**
- Verify `SPRING_PROFILES_ACTIVE` environment variable
- Check configuration file names

### Debug Mode
```bash
# Enable debug logging
export LOGGING_LEVEL_ROOT=DEBUG
export SPRING_PROFILES_ACTIVE=your-profile
./gradlew bootRun
```

## Support

For issues related to specific platforms:
- Azure MySQL: Issue #15
- MongoDB: Issue #16
- General deployment: Create a new issue

## Contributing

When adding new platform support:
1. Create new application-{platform}.properties file
2. Add Docker Compose configuration if applicable
3. Update this README
4. Add integration tests
5. Update deployment scripts
Loading