kind: pipeline
name: build
type: docker

platform:
  os: linux
  arch: amd64

steps:
  - name: build-master
    image: plugins/docker
    when:
      branch:
        - master
    environment:
      NEXT_PUBLIC_API_HOST: https://pig.vault48.org/
      NEXT_PUBLIC_REMOTE_CURRENT: https://pig.vault48.org/static/
      NEXT_PUBLIC_PUBLIC_HOST: https://vault48.org/
    settings:
      dockerfile: docker/nextjs/Dockerfile
      build_args_from_env:
        - NEXT_PUBLIC_API_HOST
        - NEXT_PUBLIC_REMOTE_CURRENT
        - NEXT_PUBLIC_PUBLIC_HOST
      tag:
        - ${DRONE_BRANCH}
      custom_labels:
        - "commit=${DRONE_COMMIT_SHA}"
      username:
        from_secret: global_docker_login
      password:
        from_secret: global_docker_password
      registry:
        from_secret: global_docker_registry
      repo:
        from_secret: docker_repo
  - name: build-develop
    image: plugins/docker
    when:
      branch:
        - develop
    environment:
      NEXT_PUBLIC_API_HOST: https://pig.staging.vault48.org/
      NEXT_PUBLIC_REMOTE_CURRENT: https://pig.staging.vault48.org/static/
      NEXT_PUBLIC_PUBLIC_HOST: https://staging.vault48.org/
    settings:
      dockerfile: docker/nextjs/Dockerfile
      build_args_from_env:
        - NEXT_PUBLIC_API_HOST
        - NEXT_PUBLIC_REMOTE_CURRENT
        - NEXT_PUBLIC_PUBLIC_HOST
      tag:
        - ${DRONE_BRANCH}
      custom_labels:
        - "commit=${DRONE_COMMIT_SHA}"
      username:
        from_secret: global_docker_login
      password:
        from_secret: global_docker_password
      registry:
        from_secret: global_docker_registry
      repo:
        from_secret: docker_repo

volumes:
  - name: cache
    host:
      path: /tmp/cache
