turtl / tracker

This project is for tracking issues, bug reports, and progress on the entire Turtl project.
67 stars 3 forks source link

Docker version of server do not send validation mail #355

Open bnounours opened 4 years ago

bnounours commented 4 years ago

Hello,

I try to receive validation email from the server inside the docker. First, the environment variable are not explained in the config.yaml.docker. I finally found that I have to declare

      TURTL_PLUGINS_PLUGIN_LOCATION: './example-plugins'
      TURTL_SERVER_PLUGIN_REPO: '-'
      TURTL_PLUGINS_EMAIL_ENABLED: 'true'
      TURTL_PLUGINS_EMAIL_ENDPOINT: 'smtp://root@XXX.XXX.XXX.XXX?pool=true'
      TURTL_PLUGINS_EMAIL_DEFAULTS: ''

But it did not work because the package for the plugin email was not installed I modified the scripts/install-plugins.sh to put in comment theses 2 lines:

#   git clone ${TURTL_SERVER_PLUGIN_REPO} "${TURTL_SERVER_PLUGIN_LOCATION}" || \
#       { echo "Error grabbing plugins"; exit 1; }

But I had an error with the command pushd.

Finally I changed the Dockerfile to force installation of package

RUN apk add -U bash git &&\
  npm install --production &&\
  ./scripts/install-plugins.sh &&\
  cd example-plugins &&\
  npm install &&\
  cd .. &&\
  mkdir /plugins /uploads &&\
  npm audit fix

Now the server works but I don't receive any mail. Even on Debug I don't see anything. Somebody can help me to make it work ?

lsascha commented 4 years ago

I had the same issue and build the docker image myself. What i did was as follow.

  1. Copy the server/config.yaml.docker file and modify it slightly. i think important was to set plugins.email.enabled: true

  2. put it as config.yaml besides a custom build script in a git repo. (could be obsolete with using the environment variable TURTL_CONFIG_OVERRIDE but i was not much successful with it. I think it expects a json format) maybe like TURTL_CONFIG_OVERRIDE: '{"plugins": {"email": {"enabled": true, "endpoint": "smtps://yoursmtpserver", "defaults": {}}}}'

  3. to build use a nodejs image and use the script:

    stage: build
    script:
    - git clone https://github.com/turtl/server.git
    # use custom config
    - rm -f server/config/config.yaml.docker && cp config.yaml server/config/config.yaml.docker
    # enable example plugins
    - mv server/example-plugins server/plugins
    - cd server/plugins
    - npm install
    artifacts:
    paths:
      - server/
  4. have it upload your image to your registry

  5. in my docker-compose.yaml on the server defined all these environment variables:

    environment:
      TURTL_DB_HOST: postgres-db
      TURTL_DB_PORT: 5432
      TURTL_DB_DATABASE: turtl
      TURTL_DB_USER: turtl
      TURTL_DB_PASSWORD: turtl
      TURTL_APP_SECURE_HASH_SALT: $TURTL_APP_SECURE_HASH_SALT
      TURTL_APP_EMAILS_ADMIN: your@email.de
      TURTL_APP_EMAILS_INFO: your@email.de
      TURTL_APP_EMAILS_INVITES: your@email.de
      TURTL_PLUGINS_EMAIL_ENABLED: 'true'
      TURTL_PLUGINS_EMAIL_ENDPOINT: 'smtps://yoursmtpserver'
      TURTL_APP_API_URL: 'https://$TRAEFIK_DOMAIN'

after that i got e-mails, but the confirmation link did not show anything since it redirects to a http server which you would need, but it was still activated.

hope that helps and might show what is missing.

bnounours commented 4 years ago

Hello @lsascha,

Thx for replying :)

Your solution did not work for me, but gave me clue to "my solution".

After having a look at the doc of nodemailer, I found that the first argument which is taken from endpoint in configuration can be an object. After some try I found a configuration working that I put in the config directly

plugins:
  plugin_location: '/plugins'
  analytics:
    enabled: false
  email:
    enabled: true 
    endpoint: 
      host: "localhost"
      port: 25
      secure: false
      tls:
        rejectUnauthorized: false
  premium:
    enabled: false

Of course I still have to force installation of package from this plugin to make this work