setup completed
This commit is contained in:
parent
acfbc80d1a
commit
7d3bc2a014
188
README-DEVELOPMENT.md
Normal file
188
README-DEVELOPMENT.md
Normal file
@ -0,0 +1,188 @@
|
||||
# Placebo.mk - Development Setup
|
||||
|
||||
This project supports two development modes:
|
||||
1. **Docker Mode** (Recommended): All services run in Docker containers
|
||||
2. **Local Mode**: Services run locally with npm, PostgreSQL in Docker
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Option 1: Docker Mode (Recommended)
|
||||
```bash
|
||||
# Start all services in Docker
|
||||
npm run docker:up
|
||||
|
||||
# Or use the alias
|
||||
npm run dev:docker
|
||||
```
|
||||
|
||||
Services will be available at:
|
||||
- Frontend: http://localhost:5173
|
||||
- Backend API: http://localhost:3000
|
||||
- CMS (Strapi): http://localhost:1337/admin
|
||||
- PostgreSQL: localhost:5432
|
||||
|
||||
### Option 2: Local Mode
|
||||
```bash
|
||||
# Start PostgreSQL in Docker
|
||||
docker-compose -f docker-compose.dev.yml up postgres
|
||||
|
||||
# In another terminal, start backend and frontend locally
|
||||
npm run dev:local
|
||||
```
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
### Backend Configuration
|
||||
The backend uses `.env` files for configuration:
|
||||
|
||||
- `.env` - Default Docker configuration (committed)
|
||||
- `.env.local` - Local development configuration (not committed)
|
||||
- `.env.docker` - Docker configuration template
|
||||
- `.env.example` - Example configuration
|
||||
|
||||
**Switching between modes:**
|
||||
```bash
|
||||
# Switch to local mode
|
||||
cd backend && npm run dev:local
|
||||
|
||||
# Switch back to Docker mode
|
||||
cd backend && npm run dev:reset-env
|
||||
```
|
||||
|
||||
### Frontend Configuration
|
||||
The frontend also uses `.env` files:
|
||||
|
||||
- `.env` - Default Docker configuration (committed)
|
||||
- `.env.local` - Local development configuration (not committed)
|
||||
- `.env.docker` - Docker configuration template
|
||||
|
||||
**API URL differences:**
|
||||
- Docker: `VITE_API_URL=http://backend:3000/api/v1`
|
||||
- Local: `VITE_API_URL=http://localhost:3000/api/v1`
|
||||
|
||||
## Development Scripts
|
||||
|
||||
### Root Level Scripts
|
||||
```bash
|
||||
# Docker commands
|
||||
npm run docker:up # Start all services
|
||||
npm run docker:down # Stop all services
|
||||
npm run docker:build # Rebuild containers
|
||||
npm run docker:logs # View logs
|
||||
npm run docker:ps # Check container status
|
||||
|
||||
# Development modes
|
||||
npm run dev:docker # Docker mode (alias for docker:up)
|
||||
npm run dev:local # Local mode
|
||||
|
||||
# Utility
|
||||
npm run reset:env # Reset .env files to Docker defaults
|
||||
npm run lint # Run linting on all services
|
||||
npm run type-check # Run TypeScript checks
|
||||
```
|
||||
|
||||
### Backend Scripts (in backend/ directory)
|
||||
```bash
|
||||
npm run dev:docker # Start in Docker mode (uses .env)
|
||||
npm run dev:local # Start in local mode (uses .env.local)
|
||||
npm run start:dev # Original NestJS dev command
|
||||
npm run dev:reset-env # Reset .env to Docker defaults
|
||||
```
|
||||
|
||||
### Frontend Scripts (in frontend/ directory)
|
||||
```bash
|
||||
npm run dev:docker # Start in Docker mode
|
||||
npm run dev:local # Start in local mode
|
||||
npm run dev # Original Vite dev command
|
||||
npm run dev:reset-env # Reset .env to Docker defaults
|
||||
```
|
||||
|
||||
## Database Management
|
||||
|
||||
### PostgreSQL in Docker
|
||||
The PostgreSQL container is configured with:
|
||||
- Host: `localhost:5432` (from host) or `postgres:5432` (from Docker)
|
||||
- Database: `placebo_backend_db` (backend), `placebo_cms_db` (CMS)
|
||||
- User: `placebo_user`
|
||||
- Password: `placebo_password`
|
||||
|
||||
### Connecting to Database
|
||||
```bash
|
||||
# From host machine
|
||||
psql -h localhost -p 5432 -U placebo_user -d placebo_backend_db
|
||||
|
||||
# From within Docker container
|
||||
psql -h postgres -p 5432 -U placebo_user -d placebo_backend_db
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
placeboMk/
|
||||
├── backend/ # NestJS backend API
|
||||
│ ├── .env # Docker configuration (default)
|
||||
│ ├── .env.local # Local development configuration
|
||||
│ └── src/
|
||||
├── frontend/ # React/Vite frontend
|
||||
│ ├── .env # Docker configuration (default)
|
||||
│ ├── .env.local # Local development configuration
|
||||
│ └── src/
|
||||
├── cms/cms/ # Strapi CMS
|
||||
├── docker-compose.yml # Production configuration
|
||||
├── docker-compose.dev.yml # Development configuration
|
||||
└── package.json # Root scripts
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Port conflicts**
|
||||
- Check if ports 3000, 5173, 1337, 5432 are free
|
||||
- Use `lsof -i :3000` to check what's using a port
|
||||
|
||||
2. **Database connection errors**
|
||||
- Ensure PostgreSQL container is running: `docker ps`
|
||||
- Check logs: `docker logs placebo-postgres-dev`
|
||||
- Verify credentials in `.env` files
|
||||
|
||||
3. **Environment configuration**
|
||||
- Run `npm run reset:env` to reset to Docker defaults
|
||||
- Ensure `.env.local` exists for local development
|
||||
|
||||
4. **Docker container issues**
|
||||
- Rebuild containers: `npm run docker:build`
|
||||
- Clear Docker cache: `docker system prune -f`
|
||||
|
||||
### Reset Everything
|
||||
```bash
|
||||
# Stop and remove containers
|
||||
npm run docker:down
|
||||
docker system prune -f
|
||||
|
||||
# Reset environment files
|
||||
npm run reset:env
|
||||
|
||||
# Start fresh
|
||||
npm run docker:up
|
||||
```
|
||||
|
||||
## Production Deployment
|
||||
|
||||
For production, use:
|
||||
```bash
|
||||
docker-compose -f docker-compose.yml up -d
|
||||
```
|
||||
|
||||
Production configuration:
|
||||
- Uses separate `docker-compose.yml`
|
||||
- Includes Nginx reverse proxy
|
||||
- No hot reload, optimized builds
|
||||
- Health checks and proper logging
|
||||
|
||||
## Notes
|
||||
|
||||
- **Docker-first approach**: `.env` files are configured for Docker by default
|
||||
- **Local development**: Uses `.env.local` files when running services locally
|
||||
- **PostgreSQL**: Always runs in Docker for consistency
|
||||
- **Secrets**: Never commit actual secrets to repository
|
||||
@ -1,7 +1,34 @@
|
||||
PORT=3000
|
||||
DATABASE_PATH=./database.sqlite
|
||||
NODE_ENV=development
|
||||
FRONTEND_URL=http://localhost:5173
|
||||
# Environment Configuration Template
|
||||
# Copy to .env and adjust values for your setup
|
||||
|
||||
# ===== DOCKER MODE (services in containers) =====
|
||||
# Use these values when running in Docker Compose
|
||||
# DATABASE_HOST=postgres
|
||||
# STRAPI_URL=http://cms:1337
|
||||
|
||||
# ===== LOCAL MODE (backend locally, DB in Docker) =====
|
||||
# Use these values when running backend locally with npm run dev
|
||||
DATABASE_HOST=localhost
|
||||
STRAPI_URL=http://localhost:1337
|
||||
|
||||
# ===== COMMON CONFIGURATION =====
|
||||
NODE_ENV=development
|
||||
PORT=3000
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_PORT=5432
|
||||
DATABASE_USERNAME=placebo_user
|
||||
DATABASE_PASSWORD=placebo_password
|
||||
DATABASE_NAME=placebo_backend_db
|
||||
DATABASE_SYNCHRONIZE=true
|
||||
DATABASE_LOGGING=true
|
||||
|
||||
# JWT Configuration
|
||||
JWT_SECRET=dev-jwt-secret-change-in-production
|
||||
JWT_EXPIRATION=3600
|
||||
|
||||
# CORS Configuration
|
||||
CORS_ORIGIN=http://localhost:5173
|
||||
|
||||
# Strapi CMS Configuration
|
||||
STRAPI_API_TOKEN=your-strapi-api-token-here
|
||||
|
||||
@ -19,7 +19,10 @@
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||
"dev:docker": "nest start --watch",
|
||||
"dev:local": "cp -f .env.local .env && nest start --watch",
|
||||
"dev:reset-env": "cp -f .env.docker .env"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/axios": "^4.0.1",
|
||||
|
||||
@ -8,6 +8,7 @@ services:
|
||||
environment:
|
||||
POSTGRES_USER: placebo_user
|
||||
POSTGRES_PASSWORD: placebo_password
|
||||
POSTGRES_DB: placebo_backend_db
|
||||
volumes:
|
||||
- postgres_data_dev:/var/lib/postgresql/data
|
||||
- ./scripts/init-postgres-dev.sql:/docker-entrypoint-initdb.d/init-postgres-dev.sql
|
||||
@ -22,21 +23,11 @@ services:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: placebo-backend-dev
|
||||
env_file:
|
||||
- ./backend/.env # Use the .env file for configuration
|
||||
environment:
|
||||
# Only override if needed, most config is in .env file
|
||||
NODE_ENV: development
|
||||
DATABASE_HOST: postgres
|
||||
DATABASE_PORT: 5432
|
||||
DATABASE_USERNAME: placebo_user
|
||||
DATABASE_PASSWORD: placebo_password
|
||||
DATABASE_NAME: placebo_backend_db
|
||||
DATABASE_SYNCHRONIZE: "true"
|
||||
DATABASE_LOGGING: "true"
|
||||
JWT_SECRET: dev-jwt-secret
|
||||
JWT_EXPIRATION: 3600
|
||||
CORS_ORIGIN: http://localhost:5173
|
||||
PORT: 3000
|
||||
STRAPI_URL: http://cms:1337
|
||||
STRAPI_API_TOKEN: 578d628f62df967ff95f95bedb205b5d10bbf792340519c8c467d6473208e16b3918151a97b49fa2285a53df0ec8e340a9ca555b01a654bd22152847840e6a368ee626a6f1338ce2f23790c171013b263ec80fbaf116e2b459d3663b234d08855fd0eb631991ed15bb94f7dbb0b80f190352965c72c7fd327c73629ceff38fbb
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
@ -45,8 +36,8 @@ services:
|
||||
- ./backend/src:/app/src
|
||||
- ./backend/package.json:/app/package.json
|
||||
- ./backend/package-lock.json:/app/package-lock.json
|
||||
- ./backend/.env:/app/.env
|
||||
command: npm run start:dev
|
||||
- ./backend/.env:/app/.env # Mount .env file into container
|
||||
command: npm run dev:docker
|
||||
networks:
|
||||
- placebo-network-dev
|
||||
|
||||
@ -56,10 +47,10 @@ services:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: placebo-frontend-dev
|
||||
env_file:
|
||||
- ./frontend/.env # Use the .env file for configuration
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
VITE_API_URL: http://localhost:3000/api/v1
|
||||
VITE_CMS_URL: http://localhost:1337
|
||||
ports:
|
||||
- "5173:5173"
|
||||
depends_on:
|
||||
@ -75,7 +66,7 @@ services:
|
||||
- ./frontend/tsconfig.node.json:/app/tsconfig.node.json
|
||||
- ./frontend/tailwind.config.js:/app/tailwind.config.js
|
||||
- ./frontend/.env:/app/.env
|
||||
command: npm run dev
|
||||
command: npm run dev:docker
|
||||
networks:
|
||||
- placebo-network-dev
|
||||
|
||||
|
||||
@ -1 +1,13 @@
|
||||
# Frontend Environment Configuration
|
||||
# Copy to .env and adjust for your setup
|
||||
|
||||
# ===== DOCKER MODE (frontend in container) =====
|
||||
# Use when frontend runs in Docker container
|
||||
# VITE_API_URL=http://backend:3000/api/v1
|
||||
|
||||
# ===== LOCAL MODE (frontend runs locally) =====
|
||||
# Use when frontend runs locally with npm run dev
|
||||
VITE_API_URL=http://localhost:3000/api/v1
|
||||
|
||||
# ===== COMMON =====
|
||||
VITE_CMS_URL=http://localhost:1337
|
||||
|
||||
@ -12,7 +12,10 @@
|
||||
"type-check": "tsc --noEmit",
|
||||
"test": "vitest",
|
||||
"test:ui": "vitest --ui",
|
||||
"test:coverage": "vitest --coverage"
|
||||
"test:coverage": "vitest --coverage",
|
||||
"dev:docker": "vite",
|
||||
"dev:local": "cp -f .env.local .env && vite",
|
||||
"dev:reset-env": "cp -f .env.docker .env"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-label": "^2.1.8",
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api/v1';
|
||||
|
||||
// Debug logging
|
||||
console.log('API_BASE_URL:', API_BASE_URL);
|
||||
console.log('VITE_API_URL env:', import.meta.env.VITE_API_URL);
|
||||
|
||||
export interface Article {
|
||||
id: string;
|
||||
title: string;
|
||||
|
||||
29003
package-lock.json
generated
Normal file
29003
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
package.json
Normal file
35
package.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "placebo-mk",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Placebo.mk - Macedonian news site with sarcastic tone",
|
||||
"scripts": {
|
||||
"docker:up": "docker-compose -f docker-compose.dev.yml up",
|
||||
"docker:down": "docker-compose -f docker-compose.dev.yml down",
|
||||
"docker:build": "docker-compose -f docker-compose.dev.yml build",
|
||||
"docker:logs": "docker-compose -f docker-compose.dev.yml logs -f",
|
||||
"docker:restart": "docker-compose -f docker-compose.dev.yml restart",
|
||||
"docker:ps": "docker-compose -f docker-compose.dev.yml ps",
|
||||
"dev:docker": "npm run docker:up",
|
||||
"dev:local": "echo 'Starting local development...' && concurrently \"npm run dev:backend:local\" \"npm run dev:frontend:local\"",
|
||||
"dev:backend:local": "cd backend && npm run dev:local",
|
||||
"dev:frontend:local": "cd frontend && npm run dev:local",
|
||||
"dev:backend:docker": "cd backend && npm run dev:docker",
|
||||
"dev:frontend:docker": "cd frontend && npm run dev:docker",
|
||||
"reset:env": "cd backend && npm run dev:reset-env && cd ../frontend && npm run dev:reset-env",
|
||||
"lint": "concurrently \"cd backend && npm run lint\" \"cd frontend && npm run lint\"",
|
||||
"lint:fix": "concurrently \"cd backend && npm run lint:fix\" \"cd frontend && npm run lint:fix\"",
|
||||
"type-check": "concurrently \"cd backend && npm run type-check\" \"cd frontend && npm run type-check\"",
|
||||
"db:backup": "./scripts/db-backup.sh",
|
||||
"db:restore": "./scripts/db-restore.sh",
|
||||
"db:reset": "./scripts/db-reset.sh"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^8.2.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"backend",
|
||||
"frontend",
|
||||
"cms/cms"
|
||||
]
|
||||
}
|
||||
24
scripts/db-backup.sh
Executable file
24
scripts/db-backup.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Database Backup Script
|
||||
# Backs up PostgreSQL databases from Docker container
|
||||
|
||||
set -e
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
BACKUP_DIR="./backups"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
echo "📦 Backing up PostgreSQL databases..."
|
||||
|
||||
# Backup backend database
|
||||
echo "Backing up placebo_backend_db..."
|
||||
docker exec placebo-postgres-dev pg_dump -U placebo_user -d placebo_backend_db > "$BACKUP_DIR/backend_db_$TIMESTAMP.sql"
|
||||
|
||||
# Backup CMS database
|
||||
echo "Backing up placebo_cms_db..."
|
||||
docker exec placebo-postgres-dev pg_dump -U placebo_user -d placebo_cms_db > "$BACKUP_DIR/cms_db_$TIMESTAMP.sql"
|
||||
|
||||
echo "✅ Backups created in $BACKUP_DIR/"
|
||||
echo "Backend: backend_db_$TIMESTAMP.sql"
|
||||
echo "CMS: cms_db_$TIMESTAMP.sql"
|
||||
41
scripts/db-reset.sh
Executable file
41
scripts/db-reset.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Database Reset Script
|
||||
# Resets PostgreSQL databases to initial state
|
||||
|
||||
set -e
|
||||
|
||||
echo "⚠️ WARNING: This will reset ALL databases!"
|
||||
read -p "Are you sure? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Cancelled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🔄 Resetting PostgreSQL databases..."
|
||||
|
||||
# Stop backend and CMS to avoid connection issues
|
||||
echo "Stopping backend and CMS containers..."
|
||||
docker stop placebo-backend-dev placebo-cms-dev 2>/dev/null || true
|
||||
|
||||
# Drop and recreate databases
|
||||
echo "Resetting databases..."
|
||||
docker exec placebo-postgres-dev psql -U placebo_user -c "DROP DATABASE IF EXISTS placebo_backend_db;" postgres
|
||||
docker exec placebo-postgres-dev psql -U placebo_user -c "DROP DATABASE IF EXISTS placebo_cms_db;" postgres
|
||||
docker exec placebo-postgres-dev psql -U placebo_user -c "CREATE DATABASE placebo_backend_db;" postgres
|
||||
docker exec placebo-postgres-dev psql -U placebo_user -c "CREATE DATABASE placebo_cms_db;" postgres
|
||||
|
||||
# Run initialization script
|
||||
echo "Running initialization script..."
|
||||
docker exec placebo-postgres-dev psql -U placebo_user -f /docker-entrypoint-initdb.d/init-postgres-dev.sql postgres
|
||||
|
||||
# Restart containers
|
||||
echo "Restarting containers..."
|
||||
docker start placebo-backend-dev placebo-cms-dev 2>/dev/null || true
|
||||
|
||||
echo "✅ Databases reset successfully!"
|
||||
echo ""
|
||||
echo "Note: Backend and CMS will need to restart their services."
|
||||
echo "For backend: docker restart placebo-backend-dev"
|
||||
echo "For CMS: docker restart placebo-cms-dev"
|
||||
34
scripts/db-restore.sh
Executable file
34
scripts/db-restore.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Database Restore Script
|
||||
# Restores PostgreSQL databases from backup
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <backup_file> [database_name]"
|
||||
echo "Example: $0 backups/backend_db_20250101_120000.sql"
|
||||
echo "Example: $0 backups/backend_db_20250101_120000.sql placebo_backend_db"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BACKUP_FILE="$1"
|
||||
DATABASE="${2:-placebo_backend_db}"
|
||||
|
||||
if [ ! -f "$BACKUP_FILE" ]; then
|
||||
echo "❌ Backup file not found: $BACKUP_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🔄 Restoring database $DATABASE from $BACKUP_FILE..."
|
||||
|
||||
# Drop and recreate database
|
||||
echo "Recreating database..."
|
||||
docker exec placebo-postgres-dev psql -U placebo_user -c "DROP DATABASE IF EXISTS $DATABASE;" postgres
|
||||
docker exec placebo-postgres-dev psql -U placebo_user -c "CREATE DATABASE $DATABASE;" postgres
|
||||
|
||||
# Restore from backup
|
||||
echo "Restoring data..."
|
||||
docker exec -i placebo-postgres-dev psql -U placebo_user -d "$DATABASE" < "$BACKUP_FILE"
|
||||
|
||||
echo "✅ Database $DATABASE restored successfully!"
|
||||
83
scripts/setup.sh
Executable file
83
scripts/setup.sh
Executable file
@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Placebo.mk Setup Script
|
||||
# This script sets up the development environment
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Setting up Placebo.mk development environment..."
|
||||
|
||||
# Check if Docker is installed
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "❌ Docker is not installed. Please install Docker first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Docker Compose is installed
|
||||
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
|
||||
echo "❌ Docker Compose is not installed. Please install Docker Compose."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check Node.js version
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo "⚠️ Node.js is not installed. Local mode won't work, but Docker mode will."
|
||||
fi
|
||||
|
||||
# Create necessary directories
|
||||
echo "📁 Creating directories..."
|
||||
mkdir -p scripts
|
||||
mkdir -p backend/uploads
|
||||
mkdir -p cms/cms/public/uploads
|
||||
|
||||
# Set up environment files
|
||||
echo "⚙️ Setting up environment files..."
|
||||
|
||||
# Backend
|
||||
if [ ! -f backend/.env ]; then
|
||||
echo "Creating backend/.env from template..."
|
||||
cp backend/.env.docker.template backend/.env
|
||||
fi
|
||||
|
||||
if [ ! -f backend/.env.local ]; then
|
||||
echo "Creating backend/.env.local from template..."
|
||||
cp backend/.env.local.template backend/.env.local
|
||||
fi
|
||||
|
||||
# Frontend
|
||||
if [ ! -f frontend/.env ]; then
|
||||
echo "Creating frontend/.env from template..."
|
||||
cp frontend/.env.docker.template frontend/.env
|
||||
fi
|
||||
|
||||
if [ ! -f frontend/.env.local ]; then
|
||||
echo "Creating frontend/.env.local from template..."
|
||||
cp frontend/.env.local.template frontend/.env.local
|
||||
fi
|
||||
|
||||
# Install root dependencies
|
||||
echo "📦 Installing root dependencies..."
|
||||
if command -v npm &> /dev/null; then
|
||||
npm install
|
||||
else
|
||||
echo "⚠️ npm not found, skipping root dependencies"
|
||||
fi
|
||||
|
||||
# Build Docker images
|
||||
echo "🐳 Building Docker images..."
|
||||
if docker compose version &> /dev/null; then
|
||||
docker compose -f docker-compose.dev.yml build
|
||||
else
|
||||
docker-compose -f docker-compose.dev.yml build
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Setup complete!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Start in Docker mode: npm run docker:up"
|
||||
echo "2. Or start in local mode:"
|
||||
echo " - First terminal: docker-compose -f docker-compose.dev.yml up postgres"
|
||||
echo " - Second terminal: npm run dev:local"
|
||||
echo ""
|
||||
echo "For more details, see README-DEVELOPMENT.md"
|
||||
42
scripts/test-env.sh
Executable file
42
scripts/test-env.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Test environment configuration
|
||||
|
||||
echo "🧪 Testing environment configuration..."
|
||||
|
||||
echo ""
|
||||
echo "=== Backend Environment ==="
|
||||
echo "Current .env DATABASE_HOST:"
|
||||
grep DATABASE_HOST backend/.env || echo "Not found"
|
||||
|
||||
echo ""
|
||||
echo "Backend .env.local DATABASE_HOST:"
|
||||
grep DATABASE_HOST backend/.env.local || echo "Not found"
|
||||
|
||||
echo ""
|
||||
echo "=== Frontend Environment ==="
|
||||
echo "Current .env VITE_API_URL:"
|
||||
grep VITE_API_URL frontend/.env || echo "Not found"
|
||||
|
||||
echo ""
|
||||
echo "Frontend .env.local VITE_API_URL:"
|
||||
grep VITE_API_URL frontend/.env.local || echo "Not found"
|
||||
|
||||
echo ""
|
||||
echo "=== Docker Compose ==="
|
||||
echo "Checking Docker Compose configuration..."
|
||||
if grep -q "env_file:" docker-compose.dev.yml; then
|
||||
echo "✓ env_file directive is present"
|
||||
else
|
||||
echo "✗ env_file directive not found"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Environment test complete!"
|
||||
echo ""
|
||||
echo "To switch to local mode:"
|
||||
echo " backend: npm run dev:local"
|
||||
echo " frontend: npm run dev:local"
|
||||
echo ""
|
||||
echo "To reset to Docker mode:"
|
||||
echo " npm run reset:env"
|
||||
Loading…
Reference in New Issue
Block a user