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

Gitlab Login on Docker Image #3078

Closed
2 tasks done
djarbz opened this issue Apr 29, 2022 · 7 comments · Fixed by #3296
Closed
2 tasks done

Gitlab Login on Docker Image #3078

djarbz opened this issue Apr 29, 2022 · 7 comments · Fixed by #3296
Assignees
Labels
enhancement New feature or request

Comments

@djarbz
Copy link

djarbz commented Apr 29, 2022

Is your feature request related to a problem? Please describe.

I wish to deploy my image to both the Gitlab Registry for my project as well as the Docker Hub.
Currently, the only way I see this possible, when using the goreleaser docker image, is to run the build twice passing different DOCKER_... env variables.

Describe the solution you'd like

I would like to be able to pass the following variable directly to the goreleaser docker image so that I can login to both Docker Hub and the Gitlab registry. I do see that an option is already added to the entrypoint script for Github.

CI_REGISTRY
CI_REGISTRY_USER
CI_REGISTRY_PASSWORD

Describe alternatives you've considered

I could run the build twice and just pass the variable as the existing docker ones.

DOCKER_REGISTRY: "$CI_REGISTRY"
DOCKER_USERNAME: "$CI_REGISTRY_USER"
DOCKER_PASSWORD: "$CI_REGISTRY_PASSWORD"

Search

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

Code of Conduct

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

Additional context

No response

@djarbz djarbz added enhancement New feature or request triage Issue pending triage by one of the maintainers labels Apr 29, 2022
@djarbz
Copy link
Author

djarbz commented Apr 29, 2022

Another option would be to add logins in the .goreleaser.yaml configuration that we can set our own environment variable to.
This would allow us to add an arbitrary amount of registries to login to.

For example:

docker_registries:
  - registry: '{ .Env.DOCKER_HUB_REGISTRY }'
    username: '{ .Env.DOCKER_HUB_USERNAME }'
    password: '{ .Env.DOCKER_HUB_PASSWORD }'
  - registry: '{ .Env.CI_REGISTRY }'
    username: '{ .Env.CI_REGISTRY_USER }'
    password: '{ .Env.CI_REGISTRY_PASSWORD }'
  - registry: '{ .Env.GITHUB_REGISTRY }'
    username: '{ .Env.GITHUB_REGISTRY_USER }'
    password: '{ .Env.GITHUB_TOKEN }'

@caarlos0
Copy link
Member

caarlos0 commented May 2, 2022

can you maybe login before running the docker image, and then mount ~/.docker/config.json?

@djarbz
Copy link
Author

djarbz commented May 3, 2022

Ok, so I tried and I keep running up empty.

release failed after 556.31s error=docker images: failed to publish artifacts: failed to push notmycloud/smtpsmartrelay:0.1.1-amd64: exit status 1: The push refers to repository [docker.io/notmycloud/smtpsmartrelay]
77b3a3588e44: Preparing
denied: requested access to the resource is denied

I do get a successful login for both Gitlab and Docker Hub in the DIND portion and then I mount the docker dir into the GoReleaser container.

WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded

I'm guessing I have something misconfigured, would you be able to look over my configurations?
.gitlab-ci.yml
.goreleaser.yaml

@caarlos0
Copy link
Member

sorry, I don't have much exp with gitlab-ci, so I can't review those.

@caarlos0
Copy link
Member

caarlos0 commented Aug 7, 2022

would something like #3296 work?

@djarbz
Copy link
Author

djarbz commented Aug 7, 2022

Yes, I think that should work.

@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Aug 12, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants