#goreleaser

1 messages · Page 1 of 1 (latest)

forest pasture
#

how to build images using Gorelease when it does not have docker installed, do i have to do a docker in docker or are there other ways like expose a service?

func (m *Nocdkp) Release(ctx context.Context, context *dagger.Directory, token *dagger.Secret) (string, error) {
    secret, err := token.Plaintext(ctx)
    if err != nil {
        return "", err
    }
    return dag.Goreleaser().
        WithGoCache().
        WithEnvVar("GITHUB_TOKEN", secret, true).
        WithSource(context).
        Release(ctx)
}
project_name: NocDkp
version: 2

env:
  - CGO_ENABLED=0

before:
  hooks:
    # You may remove this if you don't use go modules.
    - go mod tidy
    # you may remove this if you don't need go generate
    - go generate ./...

builds:
  - binary: bot
    id: bot
    main: ./app/bot/cmd
    goos:
      - linux
      - windows
      - darwin

archives:
  - formats: [tar.gz]
    # this name template makes the OS and Arch compatible with the results of `uname`.
    name_template: >-
      {{ .ProjectName }}_
      {{- title .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
      {{- if .Arm }}v{{ .Arm }}{{ end }}
    # use zip for windows archives
    format_overrides:
      - goos: windows
        formats: [zip]

dockers:
  # bot
  - dockerfile: app/bot/goreleaser.Dockerfile
    ids:
      - bot
    image_templates:
      - "ghcr.io/jensholdgaard/nocdkp/bot:{{ .Tag }}-amd64"
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--platform=linux/amd64"
  - dockerfile: app/bot/goreleaser.Dockerfile
    ids:
      - bot
    image_templates:
      - "ghcr.io/jensholdgaard/nocdkp/bot:{{ .Tag }}-arm64"
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--platform=linux/arm64"

changelog:
  sort: asc
  filters:
    exclude:
      - "^docs:"
      - "^test:"

docker_manifests:
  # bot
  - name_template: "ghcr.io/jensholdgaard/nocdkp/bot:{{ .Tag }}"
    image_templates:
      - "ghcr.io/jensholdgaard/nocdkp/bot:{{ .Tag }}-amd64"
      - "ghcr.io/jensholdgaard/nocdkp/bot:{{ .Tag }}-arm64"
  - name_template: "ghcr.io/jensholdgaard/nocdkp/bot:latest"
    image_templates:
      - "ghcr.io/jensholdgaard/nocdkp/bot:{{ .Tag }}-amd64"
      - "ghcr.io/jensholdgaard/nocdkp/bot:{{ .Tag }}-arm64"

release:
  footer: >-

    ---

    Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
#

So my thought is that i need to somehow mount docker.sock like you normally would in docker

-v /var/run/docker.sock:/var/run/docker.sock

Is there a nice way to do that with dagger?

molten drum
#

Does goreleaser have a hardcoded docker dependency?

#

@forest pasture assuming yes - you have several options:

  1. Run a docker service inside dagger. This is pretty common and works well. There is a module for it

  2. Pass the docker socket as an argument to your function, then mount it. There is a core Socket type, and a Container.withMountedSocket. The Dagger CLI accepts the path of a unix socket on your client machine.

forest pasture
forest pasture
#

when using

    {
      "name": "docker",
      "source": "github.com/shykes/x/docker@36ad35ca2d917b7fe965fa3aeb2b5f74f6dda106",
      "pin": "36ad35ca2d917b7fe965fa3aeb2b5f74f6dda106"
    },
molten drum
forest pasture
#

i get an error, but i am not sure which error it even is

molten drum
#

Also, it looks like you're in the "plain" terminal output, if you switch to the TUI output you may have more information?

forest pasture
#

i think i need to setup the cloud one moment

#

hmm it is outputting my github token in the trace 😦

molten drum
#

that's weird normally we have scrubbing in place. did you use the secret type?

nocturne granite