Local Development & Testing
Building Locally
Basic Build
docker build -t stockease-frontend:latest .Build with Custom API URL
docker build \
--build-arg VITE_API_BASE_URL=http://localhost:8081/api \
-t stockease-frontend:dev .Build with Specific Version
docker build -t stockease-frontend:v1.0.0 .Build with BuildKit (Faster)
DOCKER_BUILDKIT=1 docker build -t stockease-frontend:latest .Running Containers
Basic Run
docker run -p 8080:80 stockease-frontend:latestOpens app at http://localhost:8080
Run in Background
docker run -d -p 8080:80 --name stockease stockease-frontend:latest-d- Detached mode (background)--name stockease- Container name for easy reference
View Logs
# Real-time logs
docker logs -f stockease
# Last 50 lines
docker logs --tail 50 stockease
# Logs with timestamps
docker logs -f --timestamps stockeaseStop Container
docker stop stockease
docker rm stockeaseTesting the Container
Test HTTP Response
# Health check
curl http://localhost:8080
# Specific page
curl http://localhost:8080/admin/
# Static asset
curl -i http://localhost:8080/assets/index.jsCheck Cache Headers
curl -i http://localhost:8080/assets/index.js | grep Cache-Control
# Should show: Cache-Control: public, immutableTest SPA Routing
# These should all return index.html (not 404)
curl -I http://localhost:8080/admin
curl -I http://localhost:8080/user
curl -I http://localhost:8080/search-product
# Check Content-Type is text/html
curl -I http://localhost:8080/user | grep Content-TypeDocker Compose
Multi-Service Setup
File: docker-compose.yml
version: '3.8'
services:
frontend:
build:
context: .
args:
VITE_API_BASE_URL: http://backend:8081/api
ports:
- "3000:80"
depends_on:
- backend
environment:
- NODE_ENV=production
backend:
build: ../backend
ports:
- "8081:8081"
environment:
- DB_HOST=postgres
- API_PORT=8081
postgres:
image: postgres:15-alpine
environment:
- POSTGRES_DB=stockease
- POSTGRES_PASSWORD=password
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:Docker Compose Commands
# Start all services
docker-compose up
# Run in background
docker-compose up -d
# View logs
docker-compose logs -f frontend
# Stop services
docker-compose down
# Remove volumes (careful!)
docker-compose down -v
# Rebuild images
docker-compose build
# Restart specific service
docker-compose restart frontendImage Inspection
View Image History
docker history stockease-frontend:latestShows all layers and their sizes.
Check Image Size
docker images | grep stockeaseExample output:
stockease-frontend latest abc123def456 45MB
Inspect Full Image Details
docker inspect stockease-frontend:latest | jq '.[0] | keys'Interactive Shell
Access Container Shell
docker run -it stockease-frontend:latest /bin/sh-i- Interactive-t- Terminal
Common Commands Inside Container
# View nginx config
cat /etc/nginx/conf.d/default.conf
# Check nginx is running
ps aux | grep nginx
# List served files
ls -la /usr/share/nginx/html
# Test connectivity
curl http://localhost/
# Exit
exitDebugging
Enable Debug Mode
# Run with verbose logging
docker run --env NGINX_DEBUG=1 stockease-frontend:latestCheck Container Logs
docker logs stockease-frontendInspect Running Container
# Show processes
docker top stockease
# Show resource usage
docker stats stockease
# Show port bindings
docker port stockeaseTest Without Cache
docker build --no-cache -t stockease:test .Cleanup
Remove Container
docker rm stockeaseRemove Image
docker rmi stockease-frontend:latestRemove All Unused Images
docker image pruneRemove Everything (careful!)
docker system prune -aCommon Development Workflow
# 1. Make code changes
# 2. Build new image
docker build -t stockease:dev .
# 3. Stop old container
docker stop stockease || true
# 4. Remove old container
docker rm stockease || true
# 5. Run new container
docker run -p 8080:80 --name stockease stockease:dev
# 6. View logs
docker logs -f stockease
# 7. Test in browser
open http://localhost:8080Performance Testing
Load Test with ab
# Install Apache Bench
brew install httpd # macOS
apt-get install apache2-utils # Linux
# Run load test
ab -n 1000 -c 10 http://localhost:8080/-n 1000- 1000 requests-c 10- 10 concurrent
Monitor Resource Usage
docker stats --no-stream stockeaseRelated Documentation
Last Updated: November 2025