Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebuilt binaries cannot be used with dockers #4746

Closed
4 tasks done
jsirianni opened this issue Apr 3, 2024 · 4 comments · Fixed by #4747
Closed
4 tasks done

Prebuilt binaries cannot be used with dockers #4746

jsirianni opened this issue Apr 3, 2024 · 4 comments · Fixed by #4747
Assignees
Labels
bug Something isn't working

Comments

@jsirianni
Copy link

What happened?

This bug seems to be introduced after v1.23.0. Reproducible on v1.24 and v1.25.

I have a prebuilt builder that registers a binary that is downloaded using a script called by a pre hook.

before:
  hooks:
    - make download-prometheus-release ARCH=amd64
    - make download-prometheus-release ARCH=arm64
...
...
  - id: bindplane-prometheus
    builder: prebuilt
    prebuilt:
      path: prometheus-download/{{ .Arch }}/prometheus/prometheus
    binary: prometheus
    goos:
      - linux
    goarch:
      - amd64
      - arm64
    # When builder is "prebuilt" there are no default build targets,
    # specifically "goamd64". We would normally omit this specific
    # option.
    goamd64:
      - v1

This binary is successfully used with Linux packages using nfpms. My docker step fails, and looks like this:

  - id: prometheus-amd64
    goos: linux
    goarch: amd64
    ids:
      - prometheus
    image_templates:
      - "redacted/redacted-prometheus-amd64:latest"
    dockerfile: ./package/prometheus/Dockerfile
    use: buildx
    extra_files:
      - package/prometheus/config/prometheus.yml
      - package/prometheus/config/rules.yml
      - package/prometheus/config/web.yml
      - package/prometheus/service/container-entrypoint.sh

The dockerfile does not actually COPY the prebuilt binary, it looks like this:

ARG TAG

FROM prom/prometheus:v${TAG}

# Prometheus user has uid 65534
COPY --chown=65534 --chmod=0600 package/prometheus/config/prometheus.yml /etc/prometheus/prometheus.yml
COPY --chown=65534 --chmod=0600 package/prometheus/config/rules.yml /etc/prometheus/rules.yml
COPY --chown=65534 --chmod=0600 package/prometheus/config/web.yml /etc/prometheus/web.yml
COPY --chown=65534 --chmod=0700 package/prometheus/service/container-entrypoint.sh /container-entrypoint.sh

EXPOSE 9090

ENTRYPOINT [ "/container-entrypoint.sh" ]

I get this error

    • pipe skipped                                   reason=2 errors occurred:
	* expected to find 1 artifacts for ids [prometheus], found 0
	* expected to find 1 artifacts for ids [prometheus], found 0

How can we reproduce this?

Use a prebuilt binary builder and a docker configuration that uses that binary. On v1.23.0, it works. On v1.24 / v1.25 it fails.

goreleaser version

GitVersion:    1.25.0-pro
GitCommit:     3a9f31b650a9b9e56786b76e1688e1ad0b97fdf1
GitTreeState:  clean
BuildDate:     2024-04-03T01:32:57Z
BuiltBy:       goreleaser
GoVersion:     go1.22.1
Compiler:      gc
ModuleSum:     unknown
Platform:      darwin/arm64

GoReleaser Check

  • goreleaser check shows no errors

Search

  • I did search for other open and closed issues before opening this

Supporter

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@jsirianni jsirianni added bug Something isn't working triage Issue pending triage by one of the maintainers labels Apr 3, 2024
@caarlos0
Copy link
Member

caarlos0 commented Apr 3, 2024

Hey!

Yeah, the problem is that it wasn't properly checking things before.

In your case, the problem is that you are including builds with id prometheus, but seems like there aren't any. You can simply remove that line:

 - id: prometheus-amd64
    goos: linux
    goarch: amd64
    # remove these:
    # ids:
    #  - prometheus
    image_templates:
      - "redacted/redacted-prometheus-amd64:latest"
    dockerfile: ./package/prometheus/Dockerfile
    use: buildx
    extra_files:
      - package/prometheus/config/prometheus.yml
      - package/prometheus/config/rules.yml
      - package/prometheus/config/web.yml
      - package/prometheus/service/container-entrypoint.sh

that way, you'll hint goreleaser you don't expect to include any builds, and everything should be fine.

@caarlos0
Copy link
Member

caarlos0 commented Apr 3, 2024

this should probably be ported to the OSS version as well

@caarlos0
Copy link
Member

caarlos0 commented Apr 3, 2024

#4747

@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Apr 3, 2024
@jsirianni
Copy link
Author

Thanks, this worked for me!

caarlos0 added a commit that referenced this issue Apr 3, 2024
refs https://github.com/orgs/goreleaser/discussions/4469 closes
#4746

Also made the error better, and added more details to the docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants