# https://taskfile.dev

version: '3'

tasks:
  docker-build-web:
    desc: Build the tasknote-web prod-ready docker image, tagging it as candidate
    cmd: docker build --no-cache --build-arg VITE_BUILD="v999-$(date '+%Y-%m-%d-%H%M%S')" --build-arg SOURCE_PR="v999-123456789-$(date '+%Y-%m-%d-%H%M%S')" -t rmcampos/tasknote-app:latest ./client

  docker-build-api:
    desc: Build the tasknote-api prod-ready docker image, tagging it as candidate
    cmd: cd server && mvn -Pnative -DskipTests spring-boot:build-image -Dspring-boot.build-image.imageName=rmcampos/tasknote-api:latest -Dspring-boot.build-image.builder=paketobuildpacks/builder-jammy-tiny:0.0.505

  prod-up-web:
    desc: Speed up the tasknote-web prod-like image, building it if required
    cmd: docker compose -f docker-compose.prod.yml up -d tasknote-web

  prod-up-api:
    desc: Speed up the tasknote-api prod-like image, building it if required
    cmd: docker compose -f docker-compose.prod.yml up -d tasknote-api

  prod-up-db:
    desc: Start the database container
    cmd: docker compose -f docker-compose.prod.yml up -d tasknote-db

  prod-up:
    desc: Speed up the prod-like images for both tasknote-api and tasknote-web, building them if required
    cmd: docker compose -f docker-compose.prod.yml up -d

  prod-stop:
    desc: Stop prod containers
    cmd: docker compose -f docker-compose.prod.yml stop

  prod-tier-down:
    desc: Stop and remove prod containers
    cmd: docker compose -f docker-compose.prod.yml down --remove-orphans

  dev-run-web:
    desc: Get the tasknote-web up and running locally inside docker ready for development
    cmd: docker compose -f docker-compose.dev.yml up -d tasknote-web

  dev-run-api:
    desc: Get the tasknote-api up and running locally inside docker ready for development
    cmd: docker compose -f docker-compose.dev.yml up -d tasknote-api

  dev-run-db:
    desc: Get the tasknote-db up and running locally inside docker ready for development
    cmd: docker compose -f docker-compose.dev.yml up -d tasknote-db

  dev-run:
    desc: Get both tasknote-web and tasknote-api up and running locally inside docker ready for development
    cmd: docker compose -f docker-compose.dev.yml up -d

  dev-stop:
    desc: Stop dev containers
    cmd: docker compose -f docker-compose.dev.yml stop

  dev-tier-down:
    desc: Stop and remove dev containers
    cmd: docker compose -f docker-compose.dev.yml down --remove-orphans
