# Docker Quick Start - TaxCore Implementation

## Prerequisites
- Docker Desktop or Docker Engine installed
- Certificate file in `FRCS_Certs_Install/` directory

## Start All Services

```bash
# Build and start all services (php-apache, postgres, redis, taxcore-service)
docker-compose up --build

# Or run in background
docker-compose up --build -d
```

## Verify Services

```bash
# Check status
docker-compose ps

# Test TaxCore service
curl http://localhost:3001/health

# Test tax rates endpoint
curl http://localhost:3001/tax-rates
```

## Access Points

- **Application**: http://localhost:8080
- **TaxCore Service**: http://localhost:3001
- **PostgreSQL**: localhost:5432
- **Redis**: localhost:6379

## View Logs

```bash
# All services
docker-compose logs -f

# TaxCore service only
docker-compose logs -f taxcore-service

# PHP service
docker-compose logs -f php-apache
```

## Browser Configuration

### Auto-Detection (Default)

The POS module **automatically detects** when running on port 8080 (Docker) and uses the correct TaxCore URL.

**No configuration needed!** It will automatically use:
- Docker (port 8080): `http://localhost:3001` or `http://<host>:3001`
- Development: `http://localhost:3001`

### Manual Configuration (Optional)

If you need to override:

```javascript
// Force direct mode (default)
localStorage.setItem('taxcore_direct', 'true');
localStorage.setItem('taxcore_service_url', 'http://localhost:3001');

// Or use proxy mode via PHP
localStorage.setItem('taxcore_direct', 'false');
```

**Direct Mode Flow:**
```
Browser → TaxCore service (port 3001) → TaxCore API
```

**Proxy Mode Flow:**
```
Browser → PHP (port 8080) → TaxCore service (internal) → TaxCore API
```

## Stop Services

```bash
# Stop all services
docker-compose down

# Stop and remove volumes (⚠️ deletes database data)
docker-compose down -v
```

## Common Issues

### Certificate Not Found
Place your certificate in `FRCS_Certs_Install/` directory:
```bash
ls -la FRCS_Certs_Install/*.pfx
```

### Port Already in Use
Change ports in `docker-compose.yaml` or stop conflicting services.

### Service Unhealthy
Check logs:
```bash
docker-compose logs taxcore-service
```

## Full Documentation

See: `docs/TaxCore_Docker_Setup.md`

---

**Quick Commands:**
```bash
# Start
docker-compose up --build -d

# Status
docker-compose ps

# Logs
docker-compose logs -f taxcore-service

# Stop
docker-compose down
```
