goreleaser / goreleaser-cross

Docker image for Golang cross-compiling with CGO
MIT License
156 stars 26 forks source link

"oa64-clang": executable file not found in $PATH #8

Closed asabya closed 2 years ago

asabya commented 2 years ago

HI @troian,

I'm trying to use goreleaser to release my project. With reference to this issue I have followed the akash .goreleaser.yaml to update my yaml file.

Tha action fails with message

cgo: C compiler "oa64-clang" not found: exec: "oa64-clang": executable file not found in $PATH

.github/workflows/release.yaml

name: Release

on:
  push:
    branches-ignore:
      - '**'
    tags:
      - 'v*.*.*'

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - name: GCC multilib
        run: |
            sudo apt-get -y install gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
      - name: Setup Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.18
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Fetch all tags
        run: git fetch --force --tags
      - name: Docker Hub Login
        run: |
          printf ${{ secrets.DOCKERHUB_TOKEN }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v2
        with:
          version: latest
          args: release --rm-dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

project_name: dfs

release:
  prerelease: auto
env:
  - GO111MODULE=on
  - CGO_ENABLED=1
builds:
  - id: dfs-darwin-amd64
    main: ./cmd/dfs
    binary: dfs
    goos:
      - darwin
    goarch:
      - amd64
    env:
      - CC=o64-clang
      - CXX=o64-clang++
    flags:
      - -v
      - -trimpath
    ldflags:
      - -s -w
      - -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
      - -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
  - id: dfs-darwin-arm64
    main: ./cmd/dfs
    binary: dfs
    goos:
      - darwin
    goarch:
      - arm64
    env:
      - CC=oa64-clang
      - CXX=oa64-clang++
    flags:
      - -v
      - -trimpath
    ldflags:
      - -s -w
      - -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
      - -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
  - id: dfs-linux-amd64
    main: ./cmd/dfs
    binary: dfs
    goos:
      - linux
    goarch:
      - amd64
    env:
      - CC=x86_64-linux-gnu-gcc
      - CXX=x86_64-linux-gnu-g++
    flags:
      - -v
      - -trimpath
    ldflags:
      - -s -w
      - -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
      - -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
      - -extldflags "-lc -lrt -lpthread --static"
  - id: dfs-linux-arm64
    main: ./cmd/dfs
    binary: dfs
    goos:
      - linux
    goarch:
      - arm64
    env:
      - CC=aarch64-linux-gnu-gcc
      - CXX=aarch64-linux-gnu-g++
    flags:
      - -v
      - -trimpath
    ldflags:
      - -s -w
      - -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
      - -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
      - -extldflags "-lc -lrt -lpthread --static"
  - id: dfs-windows-amd64
    main: ./cmd/dfs
    binary: dfs
    goos:
      - windows
    goarch:
      - amd64
    env:
      - CC=x86_64-w64-mingw32-gcc
      - CXX=x86_64-w64-mingw32-g++
    flags:
      - -v
      - -trimpath
      - -buildmode=exe
    ldflags:
      - -s -w
      - -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
      - -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}

archives:
  - id: binary
    name_template: '{{ .Binary }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
    format: binary
  - id: zip
    name_template: '{{ .Binary }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
    format: zip
checksum:
  name_template: 'checksums.txt'
snapshot:
  name_template: "{{ incpatch .Version }}-snapshot"
dockers:
  - dockerfile: Dockerfile.goreleaser
    ids:
      - dfs-linux-amd64
    image_templates:
      - "asabya/fairos-dfs:v{{ .Version }}-amd64"
    use: buildx
    goos: linux
    goarch: amd64
    build_flag_templates:
      - "--platform=linux/amd64"
      - "--pull"
      - "--label=org.opencontainers.image.created={{.Date}}"
      - "--label=org.opencontainers.image.title={{.ProjectName}}"
      - "--label=org.opencontainers.image.revision={{.FullCommit}}"
      - "--label=org.opencontainers.image.version={{.Version}}"
  - dockerfile: Dockerfile.goreleaser
    ids:
      - dfs-linux-arm64
    image_templates:
      - "asabya/fairos-dfs:v{{ .Version }}-arm64"
    use: buildx
    goos: linux
    goarch: arm64
    build_flag_templates:
      - "--platform=linux/arm64"
      - "--pull"
      - "--label=org.opencontainers.image.created={{.Date}}"
      - "--label=org.opencontainers.image.title={{.ProjectName}}"
      - "--label=org.opencontainers.image.revision={{.FullCommit}}"
      - "--label=org.opencontainers.image.version={{.Version}}"
docker_manifests:
  - name_template: asabya/fairos-dfs:v{{ .Major }}
    image_templates:
      - asabya/fairos-dfs:v{{ .Version }}-amd64
      - asabya/fairos-dfs:v{{ .Version }}-arm64
    skip_push: auto
  - name_template: asabya/fairos-dfs:v{{ .Major }}.{{ .Minor }}
    image_templates:
      - asabya/fairos-dfs:v{{ .Version }}-amd64
      - asabya/fairos-dfs:v{{ .Version }}-arm64
    skip_push: auto
  - name_template: asabya/fairos-dfs:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}{{ with .Prerelease }}-{{ . }}{{ end }}
    image_templates:
      - asabya/fairos-dfs:v{{ .Version }}-amd64
      - asabya/fairos-dfs:v{{ .Version }}-arm64
  - name_template: asabya/fairos-dfs:latest
    image_templates:
      - asabya/fairos-dfs:v{{ .Version }}-amd64
      - asabya/fairos-dfs:v{{ .Version }}-arm64

Dockerfile.goreleaser

FROM debian:bullseye

EXPOSE 9090

COPY dfs /usr/local/bin/dfs
RUN /usr/local/bin/dfs version
ENTRYPOINT ["dfs"]
asabya commented 2 years ago

Sorry, I completely overlooked the make release on release.yaml. Build works now with that.

asabya commented 2 years ago

Things work upto building docker image. It fails on publish with message

 ⨯ release failed after 3m38s                       error=docker images: failed to publish artifacts: failed to push ***/fairos-dfs:v0.8.3-rc23-amd64: exit status 1: The push refers to repository [docker.io/***/fairos-dfs]

.goreleaser.yaml release.yaml make release

asabya commented 2 years ago

resolved with DOCKER_HOST value being docker.io instead of hub.docker.io