From 756b1b46e94235fcfe9bb939d842f9bdd5afc62e Mon Sep 17 00:00:00 2001 From: Alit Indrawan Date: Mon, 13 Oct 2025 15:55:20 +0800 Subject: [PATCH] feat(docker): add docker-compose and environment config for redis and app --- .env.example | 11 +++++++++++ .gitignore | 2 ++ docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 .env.example create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..43ce67f --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +# Gmail Configuration for email service +# Enable 2-factor authentication and generate an app password +GMAIL_ACCOUNT=your-email@gmail.com +GMAIL_APP_KEY=your-app-password + +# Redis password for caching +REDIS_PASSWORD=redispassword + +# Application Configuration +NOTIFICATIONS_ENABLED=true +AUTH_JWT_SECRET=my-secret-key-change-in-production \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2d20004..c66870f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ build/ ### VS Code ### .vscode/ + +.env diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..42223c2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3.8' + +services: + # Redis service for caching + redis: + image: redis:7-alpine + container_name: blog-redis + ports: + - "6380:6379" + environment: + - REDIS_PASSWORD=${REDIS_PASSWORD:-redispassword} + command: redis-server --requirepass ${REDIS_PASSWORD:-redispassword} + volumes: + - redis_data:/data + + # Main Spring Boot application + blog-backend: + build: + context: . + dockerfile: Dockerfile + container_name: blog-backend + ports: + - "8080:8080" + environment: + - GMAIL_ACCOUNT=${GMAIL_ACCOUNT:-your-email@gmail.com} + - GMAIL_APP_KEY=${GMAIL_APP_KEY:-your-app-password} + - REDIS_PASSWORD=${REDIS_PASSWORD:-redispassword} + - NOTIFICATIONS_ENABLED=${NOTIFICATIONS_ENABLED:-true} + - AUTH_JWT_SECRET=${AUTH_JWT_SECRET:-my-secret-key} + depends_on: + - redis + volumes: + - ./logs:/app/logs + +volumes: + redis_data: \ No newline at end of file