# Separate docker configuration to isolate docker dependency away from
# mac-os runner on github actions.
release:
  disable: true

env:
  # required to support multi architecture docker builds
  - DOCKER_CLI_EXPERIMENTAL=enabled

builds:
  - id: linux-build
    binary: grype
    goos:
      - linux
    goarch:
      - amd64
      - arm64
    # set the modified timestamp on the output binary to the git timestamp to ensure a reproducible build
    mod_timestamp: &build-timestamp '{{ .CommitTimestamp }}'
    env: &build-env
      - CGO_ENABLED=0
    ldflags: &build-ldflags |
      -w
      -s
      -extldflags '-static'
      -X github.com/anchore/grype/internal/version.version={{.Version}}
      -X github.com/anchore/grype/internal/version.syftVersion={{.Env.SYFT_VERSION}}
      -X github.com/anchore/grype/internal/version.gitCommit={{.Commit}}
      -X github.com/anchore/grype/internal/version.buildDate={{.Date}}
      -X github.com/anchore/grype/internal/version.gitDescription={{.Summary}}

dockers:
  - image_templates:
      - anchore/grype:debug
      - anchore/grype:{{.Tag}}-debug
      - ghcr.io/anchore/grype:debug
      - ghcr.io/anchore/grype:{{.Tag}}-debug
    goarch: amd64
    dockerfile: Dockerfile.debug
    use: buildx
    build_flag_templates:
      - "--platform=linux/amd64"
      - "--build-arg=BUILD_DATE={{.Date}}"
      - "--build-arg=BUILD_VERSION={{.Version}}"
      - "--build-arg=VCS_REF={{.FullCommit}}"
      - "--build-arg=VCS_URL={{.GitURL}}"

  - image_templates:
      - anchore/grype:debug-arm64v8
      - anchore/grype:{{.Tag}}-debug-arm64v8
      - ghcr.io/anchore/grype:debug-arm64v8
      - ghcr.io/anchore/grype:{{.Tag}}-debug-arm64v8
    goarch: arm64
    dockerfile: Dockerfile.debug
    use: buildx
    build_flag_templates:
      - "--platform=linux/arm64/v8"
      - "--build-arg=BUILD_DATE={{.Date}}"
      - "--build-arg=BUILD_VERSION={{.Version}}"
      - "--build-arg=VCS_REF={{.FullCommit}}"
      - "--build-arg=VCS_URL={{.GitURL}}"

  - image_templates:
      - anchore/grype:latest
      - anchore/grype:{{.Tag}}
      - ghcr.io/anchore/grype:latest
      - ghcr.io/anchore/grype:{{.Tag}}
    goarch: amd64
    dockerfile: Dockerfile
    use: buildx
    build_flag_templates:
      - "--platform=linux/amd64"
      - "--build-arg=BUILD_DATE={{.Date}}"
      - "--build-arg=BUILD_VERSION={{.Version}}"
      - "--build-arg=VCS_REF={{.FullCommit}}"
      - "--build-arg=VCS_URL={{.GitURL}}"

  - image_templates:
      - anchore/grype:{{.Tag}}-arm64v8
      - ghcr.io/anchore/grype:{{.Tag}}-arm64v8
    goarch: arm64
    dockerfile: Dockerfile
    use: buildx
    build_flag_templates:
      - "--platform=linux/arm64/v8"
      - "--build-arg=BUILD_DATE={{.Date}}"
      - "--build-arg=BUILD_VERSION={{.Version}}"
      - "--build-arg=VCS_REF={{.FullCommit}}"
      - "--build-arg=VCS_URL={{.GitURL}}"

docker_manifests:
  - name_template: anchore/grype:latest
    image_templates:
      - anchore/grype:{{.Tag}}
      - anchore/grype:{{.Tag}}-arm64v8

  - name_template: anchore/grype:debug
      - anchore/grype:{{.Tag}}-debug
      - anchore/grype:{{.Tag}}-debug-arm64v8

  - name_template: anchore/grype:{{.Tag}}
    image_templates:
      - anchore/grype:{{.Tag}}
      - anchore/grype:{{.Tag}}-arm64v8

  - name_template: ghcr.io/anchore/grype:latest
    image_templates:
      - ghcr.io/anchore/grype:{{.Tag}}
      - ghcr.io/anchore/grype:{{.Tag}}-arm64v8

  - name_template: ghcr.io/anchore/grype:debug
    image_templates:
      - ghcr.io/anchore/grype:{{.Tag}}-debug
      - ghcr.io/anchore/grype:{{.Tag}}-debug-arm64v8

  - name_template: ghcr.io/anchore/grype:{{.Tag}}
    image_templates:
      - ghcr.io/anchore/grype:{{.Tag}}
      - ghcr.io/anchore/grype:{{.Tag}}-arm64v8

