Skip to content
Merged
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
186 changes: 93 additions & 93 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ services:
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${MINIO_API_INTERNAL_PORT}/minio/health/live"]
test: [ "CMD", "curl", "-f", "http://localhost:${MINIO_API_INTERNAL_PORT}/minio/health/live" ]
interval: 30s
timeout: 20s
retries: 3
Expand Down Expand Up @@ -223,7 +223,7 @@ services:
cpus: '0.2'
# Health check using existing /healthz endpoint
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${THE_MONKEYS_GATEWAY_INTERNAL_PORT}/healthz"]
test: [ "CMD", "curl", "-f", "http://localhost:${THE_MONKEYS_GATEWAY_INTERNAL_PORT}/healthz" ]
interval: 30s
timeout: 10s
retries: 3
Expand Down Expand Up @@ -262,7 +262,7 @@ services:
cpus: '0.1'
# Health check is built into Dockerfile, but can override here
healthcheck:
test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_AUTHZ_INTERNAL_PORT}"]
test: [ "CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_AUTHZ_INTERNAL_PORT}" ]
interval: 30s
timeout: 10s
retries: 3
Expand All @@ -284,10 +284,10 @@ services:
- db-migrations
- the_monkeys_db
volumes:
- ./profile:/app/profile # Mount existing production files where code expects them
- ./blogs:/app/blogs # Mount existing production files where code expects them
- ./local_profiles:/app/local_profiles # Mount local profiles sync directory
- ./local_blogs:/app/local_blogs # Mount local blogs sync directory
- ./profile:/app/profile # Mount existing production files where code expects them
- ./blogs:/app/blogs # Mount existing production files where code expects them
- ./local_profiles:/app/local_profiles # Mount local profiles sync directory
- ./local_blogs:/app/local_blogs # Mount local blogs sync directory
ports:
- "${MICROSERVICES_STORAGE_PORT}:${MICROSERVICES_STORAGE_INTERNAL_PORT}"
restart: unless-stopped
Expand All @@ -304,7 +304,7 @@ services:
cpus: '0.2'
# Health check
healthcheck:
test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_STORAGE_INTERNAL_PORT}"]
test: [ "CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_STORAGE_INTERNAL_PORT}" ]
interval: 30s
timeout: 10s
retries: 3
Expand Down Expand Up @@ -343,7 +343,7 @@ services:
cpus: '0.2'
# Health check
healthcheck:
test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_USER_INTERNAL_PORT}"]
test: [ "CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_USER_INTERNAL_PORT}" ]
interval: 30s
timeout: 10s
retries: 3
Expand Down Expand Up @@ -383,94 +383,94 @@ services:
cpus: '0.2'
# Health check
healthcheck:
test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_BLOG_INTERNAL_PORT}"]
test: [ "CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_BLOG_INTERNAL_PORT}" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s

the_monkeys_notification:
container_name: "the_monkeys_notification"
build:
context: .
dockerfile: microservices/the_monkeys_notification/Dockerfile
args:
NOTIFICATION_SERVICE_PORT: ${MICROSERVICES_NOTIFICATION_PORT}
# For production, you can switch to:
# dockerfile: microservices/the_monkeys_notification/Dockerfile.distroless
networks:
- monkeys-network
depends_on:
- rabbitmq
- db-migrations
- the_monkeys_db
- elasticsearch-node1
- the_monkeys_blog
- the_monkeys_user
ports:
- "${MICROSERVICES_NOTIFICATION_PORT}:${MICROSERVICES_NOTIFICATION_INTERNAL_PORT}"
restart: unless-stopped
env_file:
- .env
# Security: Run as non-root user
user: "1001:1001"
# Resource limits for production
deploy:
resources:
limits:
memory: 256M
cpus: '0.7'
reservations:
memory: 128M
cpus: '0.2'
# Health check
healthcheck:
test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_NOTIFICATION_INTERNAL_PORT}"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
# the_monkeys_notification:
# container_name: "the_monkeys_notification"
# build:
# context: .
# dockerfile: microservices/the_monkeys_notification/Dockerfile
# args:
# NOTIFICATION_SERVICE_PORT: ${MICROSERVICES_NOTIFICATION_PORT}
# # For production, you can switch to:
# # dockerfile: microservices/the_monkeys_notification/Dockerfile.distroless
# networks:
# - monkeys-network
# depends_on:
# - rabbitmq
# - db-migrations
# - the_monkeys_db
# - elasticsearch-node1
# - the_monkeys_blog
# - the_monkeys_user
# ports:
# - "${MICROSERVICES_NOTIFICATION_PORT}:${MICROSERVICES_NOTIFICATION_INTERNAL_PORT}"
# restart: unless-stopped
# env_file:
# - .env
# # Security: Run as non-root user
# user: "1001:1001"
# # Resource limits for production
# deploy:
# resources:
# limits:
# memory: 256M
# cpus: '0.7'
# reservations:
# memory: 128M
# cpus: '0.2'
# # Health check
# healthcheck:
# test: [ "CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_NOTIFICATION_INTERNAL_PORT}" ]
# interval: 30s
# timeout: 10s
# retries: 3
# start_period: 15s

the_monkeys_ai_engine:
container_name: "the_monkeys_ai_engine"
build:
context: .
dockerfile: microservices/the_monkeys_ai/Dockerfile
args:
AI_ENGINE_PORT: ${MICROSERVICES_AI_ENGINE_PORT}
AI_ENGINE_HEALTH_PORT: ${MICROSERVICES_AI_ENGINE_HEALTH_PORT}
# For production, you can switch to:
# dockerfile: microservices/the_monkeys_ai/Dockerfile.distroless
networks:
- monkeys-network
depends_on:
- rabbitmq
- the_monkeys_db
ports:
- "${MICROSERVICES_AI_ENGINE_PORT}:${MICROSERVICES_AI_ENGINE_INTERNAL_PORT}"
- "${MICROSERVICES_AI_ENGINE_HEALTH_PORT}:${MICROSERVICES_AI_ENGINE_HEALTH_INTERNAL_PORT}" # Health check endpoint (gRPC port + 1000)
restart: unless-stopped
env_file:
- .env
environment:
- PYTHONPATH=/app
# Security: Run as non-root user
user: "1001:1001"
# Resource limits for production
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 256M
cpus: '0.3'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${MICROSERVICES_AI_ENGINE_HEALTH_INTERNAL_PORT}/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# the_monkeys_ai_engine:
# container_name: "the_monkeys_ai_engine"
# build:
# context: .
# dockerfile: microservices/the_monkeys_ai/Dockerfile
# args:
# AI_ENGINE_PORT: ${MICROSERVICES_AI_ENGINE_PORT}
# AI_ENGINE_HEALTH_PORT: ${MICROSERVICES_AI_ENGINE_HEALTH_PORT}
# # For production, you can switch to:
# # dockerfile: microservices/the_monkeys_ai/Dockerfile.distroless
# networks:
# - monkeys-network
# depends_on:
# - rabbitmq
# - the_monkeys_db
# ports:
# - "${MICROSERVICES_AI_ENGINE_PORT}:${MICROSERVICES_AI_ENGINE_INTERNAL_PORT}"
# - "${MICROSERVICES_AI_ENGINE_HEALTH_PORT}:${MICROSERVICES_AI_ENGINE_HEALTH_INTERNAL_PORT}" # Health check endpoint (gRPC port + 1000)
# restart: unless-stopped
# env_file:
# - .env
# environment:
# - PYTHONPATH=/app
# # Security: Run as non-root user
# user: "1001:1001"
# # Resource limits for production
# deploy:
# resources:
# limits:
# memory: 512M
# cpus: '1.0'
# reservations:
# memory: 256M
# cpus: '0.3'
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:${MICROSERVICES_AI_ENGINE_HEALTH_INTERNAL_PORT}/health"]
# interval: 30s
# timeout: 10s
# retries: 3
# start_period: 60s

the_monkeys_activity:
container_name: "the_monkeys_activity"
Expand Down Expand Up @@ -503,7 +503,7 @@ services:
cpus: '0.1'
# Health check is built into Dockerfile, but can override here
healthcheck:
test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_ACTIVITY_INTERNAL_PORT}"]
test: [ "CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:${MICROSERVICES_ACTIVITY_INTERNAL_PORT}" ]
interval: 30s
timeout: 10s
retries: 3
Expand All @@ -519,4 +519,4 @@ volumes:
elasticsearch-data1:
driver: local
minio_data:
driver: local
driver: local
8 changes: 6 additions & 2 deletions microservices/the_monkeys_authz/internal/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,12 @@ func (as *AuthzSvc) trackAuthActivity(user *models.TheMonkeysUser, action string
color_depth = -1
}

screen_width, _ := strconv.ParseInt(strings.Split(clientInfo.ScreenResolution, "x")[0], 10, 16)
screen_height, _ := strconv.ParseInt(strings.Split(clientInfo.ScreenResolution, "x")[1], 10, 16)
resolution := strings.Split(clientInfo.ScreenResolution, "x")
var screen_width, screen_height int64
if len(resolution) == 2 {
screen_width, _ = strconv.ParseInt(resolution[0], 10, 16)
screen_height, _ = strconv.ParseInt(resolution[1], 10, 16)
}
timezone_offset, _ := strconv.ParseInt(clientInfo.TimezoneOffset, 10, 16)

// Create comprehensive ClientInfo for activity tracking
Expand Down
13 changes: 8 additions & 5 deletions microservices/the_monkeys_blog/internal/database/v2_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import (
)

func (es *elasticsearchStorage) SaveBlog(ctx context.Context, blog map[string]interface{}) (*esapi.Response, error) {
blogId, _ := blog["blog_id"].(string)

bs, err := json.Marshal(blog)
if err != nil {
es.log.Errorf("DraftABlog: cannot marshal the blog, error: %v", err)
es.log.Errorf("SaveBlog: cannot marshal the blog %s, error: %v", blogId, err)
return nil, err
}

document := strings.NewReader(string(bs))
jsonStr := string(bs)
document := strings.NewReader(jsonStr)

blogId := blog["blog_id"].(string)
req := esapi.IndexRequest{
Index: constants.ElasticsearchBlogIndex,
DocumentID: blogId,
Expand All @@ -29,16 +31,17 @@ func (es *elasticsearchStorage) SaveBlog(ctx context.Context, blog map[string]in

insertResponse, err := req.Do(ctx, es.client)
if err != nil {
es.log.Errorf("DraftABlog: error while indexing blog, error: %+v", err)
es.log.Errorf("SaveBlog: error while indexing blog %s, error: %+v", blogId, err)
return insertResponse, err
}

if insertResponse.IsError() {
err = fmt.Errorf("DraftABlog: error indexing blog, response: %+v", insertResponse)
err = fmt.Errorf("SaveBlog: error indexing blog %s, response: %+v", blogId, insertResponse)
es.log.Error(err)
return insertResponse, err
}

es.log.Infof("SaveBlog: successfully indexed blog %s", blogId)
return insertResponse, nil
}

Expand Down
Loading
Loading