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
3 changes: 0 additions & 3 deletions .Jules/palette.md

This file was deleted.

19 changes: 19 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
# Database Configuration
DB_HOST=postgres
DB_PORT=5432
DB_NAME=db_task_manager
DB_USER=postgres
DB_PASSWORD=db_password

# JWT Configuration
JWT_SECRET=supersecreto

# API URLs
BASE_API_URL="http://nestjs:3000"

# Redis Configuration
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_TTL=300

# Rate Limiting
THROTTLE_TTL=60000
THROTTLE_LIMIT=100

# Mail Configuration (optional)
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USER=
MAIL_PASSWORD=
MAIL_FROM=noreply@example.com
32 changes: 24 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ on:
branches: [ "main" ]
pull_request:

env:
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: db_task_manager
DB_USER: postgres
DB_PASSWORD: test_password
JWT_SECRET: test_secret_for_ci
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_TTL: 300
THROTTLE_TTL: 60000
THROTTLE_LIMIT: 100

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v3
Expand All @@ -18,19 +31,22 @@ jobs:

- name: Build containers
run: docker compose -f docker-compose.yml build
- name: Start only the database (Postgres) in background
run: docker compose -f docker-compose.yml up -d postgres

- name: Start Postgres and Redis in background
run: docker compose -f docker-compose.yml up -d postgres redis

- name: Wait for Postgres to be ready
run: |
echo "Esperando a que Postgres inicie..."
until nc -z localhost 5432; do
echo "Postgres no está listo aún..."
sleep 1
done
timeout 60 bash -c 'until docker compose exec -T postgres pg_isready -U postgres -d db_task_manager; do sleep 2; done'
echo "¡Postgres está listo!"

- name: Wait for Redis to be ready
run: |
echo "Esperando a que Redis inicie..."
timeout 30 bash -c 'until docker compose exec -T redis redis-cli ping | grep -q PONG; do sleep 1; done'
echo "¡Redis está listo!"

- name: Run NestJS tests
run: docker compose -f docker-compose.yml run --rm nestjs yarn test

Expand Down
32 changes: 26 additions & 6 deletions backend/.env.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
JWT_SECRET=
DB_PORT=
DB_HOST=
DB_USER=
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=db_task_manager
DB_USER=postgres
DB_PASSWORD=
DB_NAME=
PORT=
PORT=3000

# JWT Configuration
JWT_SECRET=

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_TTL=300

# Rate Limiting
THROTTLE_TTL=60000
THROTTLE_LIMIT=100

# Mail Configuration (optional)
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USER=
MAIL_PASSWORD=
MAIL_FROM=noreply@example.com
46 changes: 35 additions & 11 deletions backend/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
# services:
# db:
# image: postgres:14.3
# restart: always
# ports:
# - '${DB_PORT}:${DB_PORT}'
# environment:
# POSTGRES_PASSWORD: ${DB_PASSWORD}
# POSTGRES_DB: ${DB_NAME}
# volumes:
# - ./posgres:/var/lib/postgresql/data
services:
db:
image: postgres:14.3
restart: always
ports:
- '${DB_PORT}:5432'
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${DB_USER} -d ${DB_NAME}']
interval: 10s
timeout: 5s
retries: 5

redis:
image: redis:7-alpine
restart: always
ports:
- '${REDIS_PORT:-6379}:6379'
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 10s
timeout: 5s
retries: 5

volumes:
postgres_data:
redis_data:
Loading