kind: pipeline
type: docker
name: deploy

steps:
  - name: build
    image: node:18-alpine
    volumes:
      - name: website-data
        path: /host-target
    commands:
      # 1. Install dependencies exactly as defined in package-lock.json
      - npm ci
      # 2. Run the build script (Tailwind + copying HTML/assets to dist/)
      - npm run build
      # 3. Clear the target folder and copy ONLY the production-ready files
      # We use dist/. to copy the contents of the folder, not the folder itself
      - rm -rf /host-target/*
      - cp -a dist/. /host-target/
      - chmod -R 755 /host-target

  - name: verify
    image: alpine:latest
    volumes:
      - name: website-data
        path: /host-target
    commands:
      - echo "Verifying deployment structure:"
      - ls -la /host-target
      - ls -la /host-target/styles/
      - echo "Deployment completed successfully"

volumes:
  - name: website-data
    host:
      path: /root/website/data/html