diff --git a/sparkyfitness/.env b/sparkyfitness/.env new file mode 100644 index 0000000..2af45c1 --- /dev/null +++ b/sparkyfitness/.env @@ -0,0 +1,117 @@ +# SparkyFitness Environment Variables +# Copy this file to .env in the root directory and fill in your own values before running 'docker-compose up'. + +# --- PostgreSQL Database Settings --- +# These values should match the ones used by your PostgreSQL container. +# For local development (running Node.js directly), use 'localhost' or '127.0.0.1' if PostgreSQL is on your host. +SPARKY_FITNESS_DB_NAME=sparkyfitness_db +#SPARKY_FITNESS_DB_USER is super user for DB initialization and migrations. +SPARKY_FITNESS_DB_USER=sparky +SPARKY_FITNESS_DB_PASSWORD=changeme_db_password +# Application database user with limited privileges. it can be changed any time after initialization. +SPARKY_FITNESS_APP_DB_USER=sparky_app +SPARKY_FITNESS_APP_DB_PASSWORD=password + +# For Docker Compose deployments, SPARKY_FITNESS_DB_HOST will be the service name (e.g., 'sparkyfitness-db'). +SPARKY_FITNESS_DB_HOST=sparkyfitness-db +#SPARKY_FITNESS_DB_PORT=5432 # Optional. Defaults to 5432 if not specified. + +# --- Backend Server Settings --- +# The hostname or IP address of the backend server. +# For Docker Compose, this is typically the service name (e.g., 'sparkyfitness-server'). +# For local development or other deployments, this might be 'localhost' or a specific IP. +SPARKY_FITNESS_SERVER_HOST=sparkyfitness-server +# The external port the server will be exposed on. +SPARKY_FITNESS_SERVER_PORT=3010 + + + +# The public URL of your frontend (e.g., https://fitness.example.com). This is crucial for CORS security. +# For local development, use http://localhost:8080. For production, use your domain with https. +SPARKY_FITNESS_FRONTEND_URL=http://192.168.1.41:8010 + +# Logging level for the server (e.g., INFO, DEBUG, WARN, ERROR) +SPARKY_FITNESS_LOG_LEVEL=ERROR + +# Node.js environment mode (e.g., development, production, test) +# Set to 'production' for deployment to ensure optimal performance and security. +NODE_ENV=production + +# Server timezone. Use a TZ database name (e.g., 'America/New_York', 'Etc/UTC'). +# This affects how dates/times are handled by the server if not explicitly managed in code. +TZ=Asia/Ho_Chi_Minh + +# --- Security Settings --- +# A 64-character hex string for data encryption. +# You can generate a secure key with the following command: +# openssl rand -hex 32 +# or +# node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" +# Changing this will invalidate existing encrypted data. You will need to delete and add External Data sources again. +SPARKY_FITNESS_API_ENCRYPTION_KEY=99f949101cfda019e7a7a844902fcb04c51a1778776cd2a02a5533d850310c1d +# For Docker Swarm/Kubernetes secrets, you can use a file-based secret: +# SPARKY_FITNESS_API_ENCRYPTION_KEY_FILE=/run/secrets/sparkyfitness_api_key + +# A secret key for signing JSON Web Tokens (JWTs). Make this a long, random, and secure string. +# You can generate a secure key with the following command: +# openssl rand -base64 32 +# or +# node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" +# This can be changed any time. +JWT_SECRET=BBRhWgtWhMxpex/hauiy93WlOnBmatjAkezrciLb7CU= +# For Docker Swarm/Kubernetes secrets, you can use a file-based secret: +# JWT_SECRET_FILE=/run/secrets/sparkyfitness_jwt_secret + +# --- Signup Settings --- +# Set to 'true' to disable new user registrations. +SPARKY_FITNESS_DISABLE_SIGNUP=false + +# --- Admin Settings --- +# Set the email of a user to automatically grant admin privileges on server startup. +# This is useful for development or initial setup. +# Example: SPARKY_FITNESS_ADMIN_EMAIL=admin@example.com +# Optional. If not set, no admin user will be created automatically. +# SPARKY_FITNESS_ADMIN_EMAIL= + +# --- Login Management Fail-Safe --- +# Set to 'true' to force email/password login to be enabled, overriding any in-app settings. +# This is a fail-safe to prevent being locked out if OIDC is misconfigured. +SPARKY_FITNESS_FORCE_EMAIL_LOGIN=true + +# --- Email Settings (Optional) --- +# Configure these variables if you want to enable email notifications (e.g., for password resets). +# If not configured, email functionality will be disabled. +# SPARKY_FITNESS_EMAIL_HOST=smtp.example.com +# SPARKY_FITNESS_EMAIL_PORT=587 +# SPARKY_FITNESS_EMAIL_SECURE=true # Use 'true' for TLS/SSL, 'false' for plain text +# SPARKY_FITNESS_EMAIL_USER=your_email@example.com +# SPARKY_FITNESS_EMAIL_PASS=your_email_password +# SPARKY_FITNESS_EMAIL_FROM=no-reply@example.com + +# --- Volume Paths (Optional) --- +# These paths define where Docker volumes will store persistent data on your host. +# If not set, Docker will manage volumes automatically in its default location. +# DB_PATH=../postgresql # Path for PostgreSQL database data +# SERVER_BACKUP_PATH=./backup # Path for server backups +# SERVER_UPLOADS_PATH=./uploads # Path for profile pictures and exercise images + + +# --- Start of Garmin Integration Settings --- +#Below variables are needed only for Garmin integration. If you don't use Garmin integration, you can remove them in your .env file. + + +# The URL for the Garmin microservice. +# For Docker Compose, this would typically be the service name and port (e.g., 'http://sparkyfitness-garmin:8000'). +# For local development, use 'http://localhost:8000' or the port you've configured. + +GARMIN_MICROSERVICE_URL=http://sparkyfitness-garmin:8000 + + +# This is used for Garmin Connect synchronization. +# If you are not using Garmin integration, you don't need this. Make sure this matches with GARMIN_MICROSERVICE_URL. +GARMIN_SERVICE_PORT=8000 + +# set to true for China region. Everything else should be false. Optional - defaults to false +GARMIN_SERVICE_IS_CN=false + +# --- End of Garmin Integration Settings --- diff --git a/sparkyfitness/docker-compose.yml b/sparkyfitness/docker-compose.yml new file mode 100644 index 0000000..95081b6 --- /dev/null +++ b/sparkyfitness/docker-compose.yml @@ -0,0 +1,70 @@ +services: + sparkyfitness-db: + image: postgres:15-alpine + restart: always + environment: + POSTGRES_DB: sparkyfitness_db + POSTGRES_USER: sparky + POSTGRES_PASSWORD: changeme_db_password + volumes: + - /docker/sparkyfitness/postgresql:/var/lib/postgresql/data + + sparkyfitness-server: + image: codewithcj/sparkyfitness_server:latest # Use pre-built image + environment: + SPARKY_FITNESS_LOG_LEVEL: ERROR + SPARKY_FITNESS_DB_USER: sparky + SPARKY_FITNESS_DB_HOST: sparkyfitness-db # Use the service name 'sparkyfitness-db' for inter-container communication + SPARKY_FITNESS_DB_NAME: sparkyfitness_db + SPARKY_FITNESS_DB_PASSWORD: changeme_db_password + SPARKY_FITNESS_APP_DB_USER: sparky_app + SPARKY_FITNESS_APP_DB_PASSWORD: password + SPARKY_FITNESS_DB_PORT: 5432 + SPARKY_FITNESS_API_ENCRYPTION_KEY: 99f949101cfda019e7a7a844902fcb04c51a1778776cd2a02a5533d850310c1d + # Uncomment the line below and comment the line above to use a file-based secret + # SPARKY_FITNESS_API_ENCRYPTION_KEY_FILE: /run/secrets/sparkyfitness_api_key + + JWT_SECRET: "BBRhWgtWhMxpex/hauiy93WlOnBmatjAkezrciLb7CU=" + # Uncomment the line below and comment the line above to use a file-based secret + # JWT_SECRET_FILE: /run/secrets/sparkyfitness_jwt_secret + SPARKY_FITNESS_FRONTEND_URL: "https://sparkyfitness.fireflylab.cc" + SPARKY_FITNESS_DISABLE_SIGNUP: true + SPARKY_FITNESS_ADMIN_EMAIL: huonghaiduynhim@gmail.com #User with this email can access the admin panel + SPARKY_FITNESS_EMAIL_HOST: ${SPARKY_FITNESS_EMAIL_HOST} + SPARKY_FITNESS_EMAIL_PORT: ${SPARKY_FITNESS_EMAIL_PORT} + SPARKY_FITNESS_EMAIL_SECURE: ${SPARKY_FITNESS_EMAIL_SECURE} + SPARKY_FITNESS_EMAIL_USER: ${SPARKY_FITNESS_EMAIL_USER} + SPARKY_FITNESS_EMAIL_PASS: ${SPARKY_FITNESS_EMAIL_PASS} + SPARKY_FITNESS_EMAIL_FROM: ${SPARKY_FITNESS_EMAIL_FROM} + GARMIN_MICROSERVICE_URL: http://sparkyfitness-garmin:8000 # Add Garmin microservice URL + restart: always + depends_on: + - sparkyfitness-db # Backend depends on the database being available + volumes: + - /docker/sparkyfitness/backup:/app/SparkyFitnessServer/backup # Mount volume for backups + - /docker/sparkyfitness/uploads:/app/SparkyFitnessServer/uploads # Mount volume for Profile pictures and excercise images + + sparkyfitness-frontend: + image: codewithcj/sparkyfitness:latest # Use pre-built image + ports: + - "8010:80" # Map host port 8080 to container port 80 (Nginx) + restart: always + depends_on: + - sparkyfitness-server # Frontend depends on the server + #- sparkyfitness-garmin # Frontend depends on Garmin microservice. Enable if you are using Garmin Connect features. + + # Garmin integration is still work in progress. Enable once table is ready. + # sparkyfitness-garmin: + # image: codewithcj/sparkyfitness_garmin:latest + # container_name: sparkyfitness-garmin + # environment: + # GARMIN_MICROSERVICE_URL: http://sparkyfitness-garmin:${GARMIN_SERVICE_PORT} + # GARMIN_SERVICE_PORT: ${GARMIN_SERVICE_PORT} + # GARMIN_SERVICE_IS_CN: ${GARMIN_SERVICE_IS_CN} # set to true for China region. Everything else should be false. Optional - defaults to false + # networks: + # - sparkyfitness-network + # restart: unless-stopped + # depends_on: + # - sparkyfitness-db + # - sparkyfitness-server +