docker-dev.sh 900 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. set -e
  3. # Define Docker Compose file and cache option
  4. COMPOSE_FILE_NAME="docker-compose-dev.yaml"
  5. CACHE=""
  6. # Uncomment the next line to enable no-cache option
  7. # CACHE="--no-cache"
  8. # Define the base Docker Compose command
  9. DCS="docker compose -f ${COMPOSE_FILE_NAME}"
  10. # Function to build and start services
  11. build_and_run() {
  12. echo "Building services..."
  13. if ! $DCS build ${CACHE}; then
  14. echo "Error: Failed to build services"
  15. exit 1
  16. fi
  17. echo "Starting services..."
  18. if ! $DCS up -d; then
  19. echo "Error: Failed to start services"
  20. exit 1
  21. fi
  22. echo "Services started successfully"
  23. echo "If you want to stop the services, run"
  24. echo "docker compose -f ${COMPOSE_FILE_NAME} down"
  25. echo "If you want to see the logs, run"
  26. echo "docker compose -f ${COMPOSE_FILE_NAME} logs -f"
  27. }
  28. # Execute build and start function
  29. build_and_run