You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Production build
docker-compose up --build
# Development build with hot reload
docker-compose --profile dev up qcx-dev --build
# Run in background
docker-compose up -d
# Stop services
docker-compose down
# View logs
docker-compose logs -f qcx
Build and Run with Docker
# Build the image
docker build -t qcx:latest .# Run the container
docker run -p 3000:3000 --env-file .env.local qcx:latest
# Run in background
docker run -d -p 3000:3000 --name qcx --env-file .env.local qcx:latest
# View logs
docker logs -f qcx
# Stop and remove
docker stop qcx && docker rm qcx
Development Commands
# Build only the deps stage (for testing)
docker build --target deps -t qcx:deps .# Build only the builder stage
docker build --target builder -t qcx:builder .# Build with no cache
docker build --no-cache -t qcx:latest .# Inspect image size
docker images qcx
# Check running containers
docker ps
# Execute commands in running container
docker exec -it qcx sh
Google Cloud Build
Manual Builds
# Submit a build
gcloud builds submit --config cloudbuild.yaml .# Submit with substitutions
gcloud builds submit \
--config cloudbuild.yaml \
--substitutions=BRANCH_NAME=main,COMMIT_SHA=$(git rev-parse HEAD) \
.# Build and tag with custom name
gcloud builds submit \
--tag gcr.io/$(gcloud config get-value project)/qcx:v1.0.0 \
.
# List triggers
gcloud builds triggers list
# Run a trigger manually
gcloud builds triggers run <TRIGGER_NAME> --branch=main
# Describe a trigger
gcloud builds triggers describe <TRIGGER_NAME># Delete a trigger
gcloud builds triggers delete <TRIGGER_NAME>
# List services
gcloud run services list
# Describe a service
gcloud run services describe qcx --region us-central1
# View service URL
gcloud run services describe qcx --region us-central1 --format='value(status.url)'# Update service configuration
gcloud run services update qcx --region us-central1 --memory 4Gi
# Delete a service
gcloud run services delete qcx --region us-central1
View Logs
# View recent logs
gcloud run services logs read qcx --region us-central1 --limit=50
# Stream logs in real-time
gcloud run services logs tail qcx --region us-central1
# Filter logs by severity
gcloud run services logs read qcx --region us-central1 --log-filter='severity>=ERROR'
Traffic Management
# Split traffic between revisions
gcloud run services update-traffic qcx \
--region us-central1 \
--to-revisions qcx-00001-abc=50,qcx-00002-def=50
# Route all traffic to latest revision
gcloud run services update-traffic qcx \
--region us-central1 \
--to-latest
# Rollback to previous revision
gcloud run services update-traffic qcx \
--region us-central1 \
--to-revisions qcx-00001-abc=100
Debugging
Local Debugging
# Build and run with verbose output
docker build --progress=plain -t qcx:debug .# Run with interactive shell
docker run -it --entrypoint /bin/sh qcx:latest
# Check container health
docker inspect --format='{{json .State.Health}}' qcx
# View container resource usage
docker stats qcx
Cloud Debugging
# View build configuration
gcloud builds describe <BUILD_ID> --format=json
# Check service account permissions
gcloud projects get-iam-policy $(gcloud config get-value project) \
--flatten="bindings[].members" \
--filter="bindings.members:serviceAccount:*@cloudbuild.gserviceaccount.com"# Test health endpoint
curl https://your-service-url.run.app/api/health
# View Cloud Run revision details
gcloud run revisions describe <REVISION_NAME> --region us-central1
Optimization
Image Size Analysis
# Use dive to analyze image layers
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
wagoodman/dive:latest qcx:latest
# Check layer sizes
docker history qcx:latest --human --format "table {{.CreatedBy}}\t{{.Size}}"
Build Cache
# Prune build cache
docker builder prune
# Prune all unused images
docker image prune -a
# Clear everything (use with caution)
docker system prune -a --volumes
Environment Variables
Local Development
# Create .env.local file
cp .env.local.example .env.local
# Edit environment variables
nano .env.local
# Run with custom env file
docker run --env-file .env.production qcx:latest