Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab Docker SMTP

I'm using the gitlab/gitlab-ce:latest docker image to set up gitlab within my company's intranet.

Doing docker-compose up -d works like a charm and I can login as root, so I changed passwords, and made myself a proper user... but never got confirmation emails.

I've been tweaking the docker-compose.yml file to try to fix the smtp settings (which I assume are the issue), and this is what I've got:

web:                                                                               
  image: gitlab/gitlab-ce:latest                                                 
  container_name: gitlab                                                         
  restart: always                                                                
  hostname: gitlab                                                               
  environment:                                                                   
    GITLAB_OMNIBUS_CONFIG: |                                                   
      external_url 'http://127.0.0.1:11141'                                  
      gitlab_rails['gitlab_shell_ssh_port'] = 11122                          
      gitlab_rails['smtp_enable'] = true                                     
      gitlab_rails['smtp_address'] = 'mail'                                  
      gitlab_rails['smtp_port'] = 25                                         
      gitlab_rails['smtp_user_name'] = 'noreply-gitlab'                      
      gitlab_rails['smtp_password'] = 'thepass'                           
      gitlab_rails['smtp_domain'] = 'ourhost.com'                         
      gitlab_rails['smtp_authentication'] = 'login'                          
      gitlab_rails['gitlab_email_from'] = '[email protected]'
      gitlab_rails['gitlab_email_reply_to'] = '[email protected]'    
  ports:                                                                         
    - '11141:11141'                                                            
    - '11122:22'                                                               
  volumes:                                                                       
    - '/srv/gitlab/config:/etc/gitlab'                                         
    - '/srv/gitlab/logs:/var/log/gitlab'                                       
    - '/srv/gitlab/data:/var/opt/gitlab'                                       

If nothing else, I'd really like to know how I can get to the logs. I know email is processed as a sidekiq job, but the sidekiq current log that I can see in the logs volume doesn't have anything about sending emails :\


In the production.log I see this:

Started POST "/users/confirmation" for 172.17.0.1 at 2017-05-18 20:26:32 +0000                                        
Processing by ConfirmationsController#create as HTML                                                                  
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"lotsoflettershere==", "user"=>{"email"=>"[email protected]"}}
Redirected to http://git.coolsrvrname.dev/users/almost_there
Completed 302 Found in 40ms (ActiveRecord: 3.9ms)

Which is just the request to send the confirmation email again, I believe. Does this mean there are no errors on gitlab's end and it is a problem with the smtp server?


Found this comment - I do not have ssl configured so I'll try that. (Also trying gitlab_rails['smtp_authentication'] = false) .... didn't work :\

like image 556
Sean Newell Avatar asked May 18 '17 20:05

Sean Newell


1 Answers

The correct yml file looked like this:

web:                                                                               
    image: gitlab/gitlab-ce:latest                                                 
    container_name: gitlab                                                         
    restart: always                                                                
    hostname: gitlab                                                               
    environment:                                                                   
        GITLAB_OMNIBUS_CONFIG: |                                                   
            external_url 'http://git.coolsrvname.dev'                                   
            gitlab_rails['gitlab_shell_ssh_port'] = 10022                          
            gitlab_rails['smtp_enable'] = true                                     
            gitlab_rails['smtp_address'] = 'mail.myhost.com'                   
            gitlab_rails['smtp_port'] = '25'                                       
            gitlab_rails['smtp_domain'] = 'mail.myhost.com'                    
            gitlab_rails['smtp_authentication'] = false                            
            gitlab_rails['gitlab_email_from'] = '[email protected]'
            gitlab_rails['gitlab_email_reply_to'] = '[email protected]'    
    ports:                                                                         
        - '10081:80'                                                               
        - '10082:443'                                                              
        - '10022:22'                                                               
    volumes:                                                                       
        - '/srv/gitlab/config:/etc/gitlab'                                         
        - '/srv/gitlab/logs:/var/log/gitlab'                                       
        - '/srv/gitlab/data:/var/opt/gitlab'                                       

This was because our smtp server has the gitlab host's ip as a trusted ip. So we set smtp auth to false. the smtp address and domain matching seemed to make it work. The external url needs to be whatever end users see or assets won't be managed correctly. Also, the port opening needs to map external ports into 80|443|22 for everything to work right.

There is probably a little tweaking that needs to happen for gitlab to receive emails, but that wasn't the intent of the question. Although I still don't know where logs are stored for outgoing smtp jobs/requests...

like image 86
Sean Newell Avatar answered Sep 25 '22 07:09

Sean Newell