apiVersion: apps/v1
kind: Deployment
metadata:
  name: aprs-app-deployment
  namespace: aprs-app
  labels:
    app: aprs-app
spec:
  replicas: 1 # Start with 1, can be scaled later
  selector:
    matchLabels:
      app: aprs-app
  template:
    metadata:
      labels:
        app: aprs-app
    spec:
      initContainers:
        - name: db-migrate
          image: aprs/aprs-app:latest # Placeholder, will be set by CI
          command: ["/app/bin/migrate"]
          envFrom:
            - secretRef:
                name: aprs-secrets
      containers:
        - name: aprs-app
          image: aprs/aprs-app:latest # Placeholder, will be set by CI
          ports:
            - containerPort: 4000 # Default Phoenix port
          envFrom:
            - secretRef:
                name: aprs-secrets
          env: # Add non-secret env vars here if any
            - name: PHX_SERVER
              value: "true"
            - name: PORT
              value: "4000"
            # The PHX_HOST is in secrets.yaml.example, it can be moved here if not sensitive
          readinessProbe:
            httpGet:
              path: /health # Assuming you'll add a health check endpoint
              port: 4000
            initialDelaySeconds: 20
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /health # Assuming you'll add a health check endpoint
              port: 4000
            initialDelaySeconds: 30
            periodSeconds: 15
# Note: For the health endpoint, you might need to create a simple one in your Phoenix router
# e.g., scope "/", AprsWeb do; get "/health", PageController, :health; end
# and a `def health(conn, _params), do: json(conn, %{status: "ok"})` in PageController.
