kind: pipeline
type: exec
name: default

steps:
  - name: build-frontend
    commands:
      - docker build --no-cache -t knck-frontend:latest .
      - docker tag knck-frontend:latest registry.knck.pl:5000/knck-frontend:latest
      - docker push registry.knck.pl:5000/knck-frontend:latest

  - name: build-backend
    commands:
      - docker build --no-cache -t knck-backend:latest ./backend
      - docker tag knck-backend:latest registry.knck.pl:5000/knck-backend:latest
      - docker push registry.knck.pl:5000/knck-backend:latest

  - name: delete
    environment:
      KUBECONFIG: /home/drone-runner/drone-kubeconfig
    commands:
      - kubectl delete deployment knck-app || true

  - name: deploy
    environment:
      KUBECONFIG: /home/drone-runner/drone-kubeconfig
    commands:
      - kubectl apply -f k8s/combined-deployment.yaml --insecure-skip-tls-verify
      - kubectl apply -f k8s/combined-service.yaml --insecure-skip-tls-verify
      - kubectl apply -f k8s/combined-ingress.yaml --insecure-skip-tls-verify

volumes:
  - name: docker_sock
    host:
      path: /var/run/docker.sock

trigger:
  branch:
    - main 