---
kind: pipeline
type: docker
name: build

steps: 
- name: build-backend
  image: plugins/docker
  environment:
    TAG:
      ${DRONE_TAG}
    COMMIT:
      ${DRONE_COMMIT}
  settings:
    insecure: true
    repo: 10.5.0.103:1222/simrail-backend
    registry: 10.5.0.103:1222
    context: './packages/backend'
    dockerfile: './packages/backend/Dockerfile'
    build_args_from_env:
      - TAG
      - COMMIT
    tags:
      - latest
      - ${DRONE_TAG}

- name: build-frontend
  image: plugins/docker
  environment:
    VITE_API_URL:
      from_secret: VITE_API_URL
    VITE_STATS_KEY:
      from_secret: VITE_STATS_KEY
  settings:
    insecure: true
    repo: 10.5.0.103:1222/simrail-frontend
    registry: 10.5.0.103:1222
    context: './packages/frontend'
    dockerfile: './packages/frontend/Dockerfile'
    build_args_from_env:
        - VITE_API_URL
        - VITE_STATS_KEY
    tags:
      - latest
      - ${DRONE_TAG##v}

trigger:
  event:
    - tag