Add development scripts and Docker Compose configuration for local environment setup
- Introduced `dev-start.sh`, `dev-stop.sh`, `dev-logs.sh`, and `dev-shell.sh` for managing the development environment. - Added `docker-compose.dev.yml` to define services for API and web applications with appropriate configurations. - Updated `README.md` to include instructions for development mode and commands for managing the environment.
This commit is contained in:
106
docker-compose.dev.yml
Normal file
106
docker-compose.dev.yml
Normal file
@@ -0,0 +1,106 @@
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: ./camera-management-api
|
||||
dockerfile: Dockerfile
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- ./camera-management-api:/app
|
||||
- /storage:/storage
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
environment:
|
||||
- PYTHONUNBUFFERED=1
|
||||
- LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib
|
||||
- PYTHONPATH=/app:/app/camera_sdk
|
||||
- TZ=America/New_York
|
||||
# Development-specific environment variables
|
||||
- FLASK_ENV=development
|
||||
- FLASK_DEBUG=1
|
||||
- PYTHONDONTWRITEBYTECODE=1
|
||||
command: >
|
||||
sh -lc "
|
||||
apt-get update && apt-get install -y libusb-1.0-0-dev;
|
||||
|
||||
# Install camera SDK if not already installed
|
||||
if [ ! -f /lib/libMVSDK.so ] && [ -f 'camera_sdk/linuxSDK_V2.1.0.49(250108)/install.sh' ]; then
|
||||
echo 'Installing camera SDK...';
|
||||
cd 'camera_sdk/linuxSDK_V2.1.0.49(250108)';
|
||||
chmod +x install.sh;
|
||||
./install.sh;
|
||||
cd /app;
|
||||
echo 'Camera SDK installed successfully';
|
||||
else
|
||||
echo 'Camera SDK already installed or install script not found';
|
||||
fi;
|
||||
|
||||
# Install Python dependencies
|
||||
if [ -f requirements.txt ]; then
|
||||
pip install --no-cache-dir -r requirements.txt;
|
||||
else
|
||||
pip install --no-cache-dir -e .;
|
||||
fi;
|
||||
|
||||
# Start the application in development mode with verbose logging
|
||||
echo 'Starting API in development mode...';
|
||||
python main.py --config config.compose.json --debug --verbose
|
||||
"
|
||||
network_mode: host
|
||||
# Keep container running for debugging
|
||||
stdin_open: true
|
||||
tty: true
|
||||
# Add labels for easier identification
|
||||
labels:
|
||||
- "com.usda-vision.service=api"
|
||||
- "com.usda-vision.environment=development"
|
||||
|
||||
web:
|
||||
image: node:20-alpine
|
||||
working_dir: /app
|
||||
env_file:
|
||||
- ./management-dashboard-web-app/.env
|
||||
volumes:
|
||||
- ./management-dashboard-web-app:/app
|
||||
environment:
|
||||
- CHOKIDAR_USEPOLLING=true
|
||||
- TZ=America/New_York
|
||||
# Development-specific environment variables
|
||||
- NODE_ENV=development
|
||||
- VITE_DEV_SERVER_HOST=0.0.0.0
|
||||
- VITE_DEV_SERVER_PORT=8080
|
||||
command: >
|
||||
sh -lc "
|
||||
echo 'Installing dependencies...';
|
||||
npm ci;
|
||||
echo 'Starting web development server...';
|
||||
npm run dev -- --host 0.0.0.0 --port 8080 --verbose
|
||||
"
|
||||
# Ensure the web container can resolve host.docker.internal on Linux
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
ports:
|
||||
- "8080:8080"
|
||||
# Keep container running for debugging
|
||||
stdin_open: true
|
||||
tty: true
|
||||
# Add labels for easier identification
|
||||
labels:
|
||||
- "com.usda-vision.service=web"
|
||||
- "com.usda-vision.environment=development"
|
||||
# Optional: Add a development database if needed
|
||||
# db:
|
||||
# image: postgres:15-alpine
|
||||
# environment:
|
||||
# POSTGRES_DB: usda_vision_dev
|
||||
# POSTGRES_USER: dev
|
||||
# POSTGRES_PASSWORD: dev
|
||||
# volumes:
|
||||
# - postgres_dev_data:/var/lib/postgresql/data
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
# labels:
|
||||
# - "com.usda-vision.service=database"
|
||||
# - "com.usda-vision.environment=development"
|
||||
|
||||
# volumes:
|
||||
# postgres_dev_data:
|
||||
Reference in New Issue
Block a user