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

should have json config support docker registry login #295

Closed
hoatle opened this issue Mar 10, 2017 · 4 comments
Closed

should have json config support docker registry login #295

hoatle opened this issue Mar 10, 2017 · 4 comments

Comments

@hoatle
Copy link
Member

hoatle commented Mar 10, 2017

This is considered a new feature, we should not introduce new feature after beta releases.

However, this is a really critical one so we break that rule with this.

The config should be something like:

{
  "provisioners": [{
    "_id": "0",
    "json": {
      "docker": {
        "registry": {
          // set true to force re-login with all the defined entries, default: false (login once)
          "force": false,
          "entries": [{
            "host": "registry.gitlab.com",
            "username": "hoatle",
            "password": "abhodihagoiege"
          }]
        }
      }
   }
}

add a Chef recipe like:

# Author:: Hoat Le <hoatle@teracy.com>
# Cookbook:: teracy-dev
# Recipe:: docker_registries
# Login into the Docker registries

registry = node['docker']['registry']

execute 'rm ~/.docker/config.json' do
    command "rm /home/vagrant/.docker/config.json || true"
    only_if { registry['force'] == true and File.exist?('/home/vagrant/.docker/config.json')}
end

registry['entries'].each do |entry|
    # private registry login
    execute 'docker login' do
        command "docker login #{entry['host']} -u #{entry['username']} -p #{entry['password']}"
        # becase we need root to execute docker-compose, not 'vagrant'
        only_if { registry['force'] == true or not File.exist?('/root/.docker/config.json') }
    end
end

execute 'copy /root/.docker/config.json to ~/.docker/config.json' do
    command "cp /root/.docker/config.json /home/vagrant/.docker/config.json"
    only_if { registry['force'] == true or not File.exist?('/home/vagrant/.docker/config.json') }
end

Anyone who needs this for v0.5.0-b2 and below, you can follow the instruction above to add this config and port this Chef recipe into your dev setup project.

@hoatle hoatle added this to the v0.5.0-c1 milestone Mar 10, 2017
@hoatle hoatle self-assigned this Mar 10, 2017
@hoatle
Copy link
Member Author

hoatle commented Mar 15, 2017

we should not put credentials into the config file, better to use prompt for username/password or at least use environment variable.

@hoatle hoatle assigned datphan and unassigned hoatle Jun 1, 2017
@hoatle
Copy link
Member Author

hoatle commented Jun 15, 2017

update: no username/password prompt.

@hoatle
Copy link
Member Author

hoatle commented Jun 15, 2017

environment variable: move out of this issue.

datphan added a commit to datphan/dev that referenced this issue Jun 19, 2017
datphan added a commit to datphan/dev that referenced this issue Jun 19, 2017
@datphan datphan mentioned this issue Jun 20, 2017
@ghost ghost assigned hoatle Jun 20, 2017
@ghost ghost added stag:in-progress and removed sprt:current labels Jun 20, 2017
datphan added a commit to datphan/dev that referenced this issue Jul 13, 2017
@hoatle hoatle removed their assignment Jul 18, 2017
datphan added a commit to datphan/dev that referenced this issue Jul 19, 2017
@phuonglm
Copy link
Contributor

verified, close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants