sameersbn / docker-gitlab

Dockerized GitLab
http://www.damagehead.com/docker-gitlab/
MIT License
7.9k stars 2.14k forks source link

SMTP configuration issue when using the Ansible docker module #361

Open akaihola opened 9 years ago

akaihola commented 9 years ago

entrypoint.sh copies SMTP configuration from environment variables only if

When using Ansible's docker module, the environment can be passed to the container like this:

- name: gitlab container
  docker:
    env:
      SMTP_ENABLED: true
      SMTP_USER: someone

The gotcha here is that Ansible tries to be smart and turns the identifier true into the boolean Python True value. The docker-py API client in turn converts that to the string "True", which isn't recognized as a true value by entrypoint.sh.

The solution is to either

I'd hate anyone else to waste as many hours as I did debugging this, so would it be reasonable to make the true value detection case insensitive?

sameersbn commented 9 years ago

@akaihola adding shopt -s nocasematch and replacing [ with [[ in the entrypoint.sh script should probably resolve this. This change would require a bit of testing to make sure it does not break anything.

sameersbn commented 9 years ago

@akaihola If you find the time can you apply the patch https://gist.github.com/sameersbn/dc6a684394f21f790f75, build and test with ansible?

sameersbn commented 9 years ago

@akaihola I tried this out. For the most part it works. But would cause problems in the yaml files where the truth value would be set to True. I don't think yaml would like that.

I think the best and quickest solution is to use quotes in the sample docker-compose.yml file.

charles-plessy commented 9 years ago

Hi, on my system (Debian Jessie, with docker-compose 1.2.0-1 installed from Stretch), the quotes in SMTP_STARTTLS="true" prevented config/initializers/smtp_settings.rb to be properly initialised with the contents of SMTP_HOST and the like. Removing the quotes solved the problem.

sameersbn commented 9 years ago

thanks for reporting this @charles-plessy. I have removed the quotes from the docker compose file now.

9monsters commented 9 years ago

Hi, There is a problem, everytime I set --env='SMTP_HOST=smtp.163.com' then ,I get this message Unable to find image ' :latest' locally .And I don't have any idea about this. Does it only support Gmail ?

sameersbn commented 9 years ago

@jiajar no.. It supports other mail hosts as well. Please provide your docker command line for me to take a closer look at whats wrong.

9monsters commented 9 years ago

There is my command docker run --name=gitlab -d \ --link=redis-gitlab:redisio \ --link=mysql-gitlab:mysql \ --publish=10022:22 --publish=10080:80 \ --env='GITLAB_PORT=10080' --env='GITLAB_SSH_PORT=10022' \ --env='SMTP_ENABLED=true' \ --env='SMTP_DOMAIN=163.com' \ --env='SMTP_HOST=smtp.163.com' --env='SMTP_PORT=25' \ --env='SMTP_USER=name@163.com' --env='SMTP_PASS=passwd' \ --volume=/srv/docker/gitlab/gitlab:/home/git/data \ sameersbn/gitlab:latest

sameersbn commented 9 years ago

@jiajar the command you pasted above has a space character after the \ character on the --env='SMTP_DOMAIN=163.com' \ line. Remove it an retry.

docker run --name=gitlab -d  \
--link=redis-gitlab:redisio \
--link=mysql-gitlab:mysql \
--publish=10022:22 --publish=10080:80 \
--env='GITLAB_PORT=10080' --env='GITLAB_SSH_PORT=10022' \
--env='SMTP_ENABLED=true' \
--env='SMTP_DOMAIN=163.com' \
--env='SMTP_HOST=smtp.163.com' --env='SMTP_PORT=25' \
--env='SMTP_USER=name@163.com' --env='SMTP_PASS=passwd' \
--volume=/srv/docker/gitlab/gitlab:/home/git/data \
sameersbn/gitlab:latest
9monsters commented 9 years ago

oh dear,that is ! Thanks !

abhas commented 9 years ago

I can confirm that quoting the string in the Ansible task did help. Adding the shopt line worked as well. Thanks a lot!

Toub commented 9 years ago

I can confirm the same behavior using docker compose.

dbrgn commented 9 years ago

Aaaah, @akaihola, I just spent about 1-2 hours debugging SMTP. Thanks for this!

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any activity for the last 60 days. It will be closed if no further activity occurs during the next 7 days. Thank you for your contributions.