Parameterisation of python settings

This commit is contained in:
James Pattinson
2025-10-25 15:27:32 +00:00
parent 77b5080bbd
commit b2a6545ace
4 changed files with 37 additions and 20 deletions

View File

@@ -1,8 +1,8 @@
# Database Configuration # Database Configuration
MYSQL_ROOT_PASSWORD=your_mysql_root_password_here MYSQL_ROOT_PASSWORD=your_mysql_root_password_here
DB_USER=ppr_user DB_USER=your_database_user_here
DB_PASSWORD=your_database_password_here DB_PASSWORD=your_database_password_here
DB_NAME=ppr DB_NAME=your_database_name_here
DB_PORT=3306 DB_PORT=3306
# API Configuration # API Configuration
@@ -13,6 +13,20 @@ API_V1_STR=/api/v1
PROJECT_NAME=Airfield PPR API NextGen PROJECT_NAME=Airfield PPR API NextGen
API_PORT_EXTERNAL=8001 API_PORT_EXTERNAL=8001
# Mail Configuration
MAIL_HOST=your_mail_host_here
MAIL_PORT=465
MAIL_USERNAME=your_mail_username_here
MAIL_PASSWORD=your_mail_password_here
MAIL_FROM=your_mail_from_address_here
MAIL_FROM_NAME=your_mail_from_name_here
# Application settings
BASE_URL=your_base_url_here
# Redis (optional)
REDIS_URL=
# Web Configuration # Web Configuration
WEB_PORT_EXTERNAL=8082 WEB_PORT_EXTERNAL=8082

View File

@@ -40,12 +40,12 @@ cd nextgen
- **Public Web Interface**: http://localhost:8082 - **Public Web Interface**: http://localhost:8082
- **Admin Interface**: http://localhost:8082/admin.html - **Admin Interface**: http://localhost:8082/admin.html
- **Reports Interface**: http://localhost:8082/reports.html - **Reports Interface**: http://localhost:8082/reports.html
- **Database**: localhost:3307 (user: ppr_user, password: ppr_password123) - **Database**: localhost:3307 (user: ppr_user, password: [configured in .env])
- **phpMyAdmin**: http://localhost:8083 - **phpMyAdmin**: http://localhost:8083
### 3. Default Login ### 3. Default Login
- **Username**: admin - **Username**: admin
- **Password**: admin123 - **Password**: [configured in database - see init_db.sql]
## API Endpoints ## API Endpoints
@@ -129,12 +129,7 @@ uvicorn app.main:app --reload
# Connect to database # Connect to database
docker exec -it ppr_nextgen_db mysql -u ppr_user -p ppr_nextgen docker exec -it ppr_nextgen_db mysql -u ppr_user -p ppr_nextgen
# View logs # When prompted for password, use the value from .env (DB_PASSWORD)
docker-compose logs -f api
docker-compose logs -f db
# Restart services
docker-compose restart
``` ```
### Testing ### Testing

View File

@@ -5,28 +5,28 @@ from typing import Optional
class Settings(BaseSettings): class Settings(BaseSettings):
# Database settings # Database settings
db_host: str = "db" # Docker service name db_host: str = "db" # Docker service name
db_user: str = "ppr_user" db_user: str
db_password: str = "ppr_password123" db_password: str
db_name: str = "ppr_nextgen" db_name: str
db_port: int = 3306 db_port: int = 3306
# Security settings # Security settings
secret_key: str = "your-secret-key-change-this-in-production" secret_key: str
algorithm: str = "HS256" algorithm: str = "HS256"
access_token_expire_minutes: int = 30 access_token_expire_minutes: int = 30
# Mail settings # Mail settings
mail_host: str = "send.one.com" mail_host: str
mail_port: int = 465 mail_port: int = 465
mail_username: str = "noreply@swansea-airport.wales" mail_username: str
mail_password: str = "SASAGoForward2155" mail_password: str
mail_from: str = "noreply@swansea-airport.wales" mail_from: str
mail_from_name: str = "Swansea Airport" mail_from_name: str
# Application settings # Application settings
api_v1_str: str = "/api/v1" api_v1_str: str = "/api/v1"
project_name: str = "Airfield PPR API" project_name: str = "Airfield PPR API"
base_url: str = "https://pprdev.swansea-airport.wales" base_url: str
# Redis settings (for future use) # Redis settings (for future use)
redis_url: Optional[str] = None redis_url: Optional[str] = None

View File

@@ -30,6 +30,14 @@ services:
ACCESS_TOKEN_EXPIRE_MINUTES: ${ACCESS_TOKEN_EXPIRE_MINUTES} ACCESS_TOKEN_EXPIRE_MINUTES: ${ACCESS_TOKEN_EXPIRE_MINUTES}
API_V1_STR: ${API_V1_STR} API_V1_STR: ${API_V1_STR}
PROJECT_NAME: ${PROJECT_NAME} PROJECT_NAME: ${PROJECT_NAME}
MAIL_HOST: ${MAIL_HOST}
MAIL_PORT: ${MAIL_PORT}
MAIL_USERNAME: ${MAIL_USERNAME}
MAIL_PASSWORD: ${MAIL_PASSWORD}
MAIL_FROM: ${MAIL_FROM}
MAIL_FROM_NAME: ${MAIL_FROM_NAME}
BASE_URL: ${BASE_URL}
REDIS_URL: ${REDIS_URL}
ports: ports:
- "${API_PORT_EXTERNAL}:8000" # Use different port to avoid conflicts with existing system - "${API_PORT_EXTERNAL}:8000" # Use different port to avoid conflicts with existing system
depends_on: depends_on: