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

Sourcing environment variables #10

Open
rhysxevans opened this issue Dec 7, 2018 · 1 comment
Open

Sourcing environment variables #10

rhysxevans opened this issue Dec 7, 2018 · 1 comment
Assignees

Comments

@rhysxevans
Copy link

Hi

Firstly thanks for the project, it is appreciated.

I am having an issue when sourcing the environment variables from the system. IE source .env , does not work with spaces

eg RELAY_MYNETWORKS=127.0.0.0/8 172.29.0.0/24 is not valid.

my docker-compose file looks like - not complete file

  smtp-relay:
    image: turgon37/smtp-relay:$SMTP_RELAY_VERSION
    container_name: smtp-relay
    hostname: smtp-relay
    restart: unless-stopped
    environment:
      - "RELAY_POSTMASTER=${RELAY_POSTMASTER}"
      - "RELAY_MYHOSTNAME=${RELAY_MYHOSTNAME}"
      - "RELAY_MYDOMAIN=${RELAY_MYDOMAIN}"
      - "RELAY_MYNETWORKS=${RELAY_MYNETWORKS}"
      - "RELAY_HOST=${RELAY_HOST}"
      - "RELAY_MODE=${RELAY_MODE}"
      - "RELAY_LOGIN=${RELAY_LOGIN}"
      - "RELAY_PASSWORD=${RELAY_PASSWORD}"
      - "RELAY_USE_TLS=${RELAY_USE_TLS}"
      - "RELAY_TLS_CA=${RELAY_TLS_CA}"
      - 'RELAY_EXTRAS_SETTINGS=compatibility_level=2'
    networks: ['stack']
    expose:
      - "25"
    volumes:
      - data-smtp-relay-auth:/data
    healthcheck:
      test: nc -zv 127.0.0.1 25 || exit 1
      interval: 60s
      timeout: 10s
      retries: 5

I am able to enter the variables as RELAY_MYNETWORKS="127.0.0.0/8 172.29.0.0/24", however that doesn't reflect in the postfix configuration correctly., you end up with mynetworks = "127.0.0.0/8 172.29.0.0/24"

I can work around this by adding the following to the start.sh script (near the top)

# Set configuration according to ENV
RELAY_MYNETWORKS=`echo "$RELAY_MYNETWORKS" | tr -d '"'`

Any chance of getting "logic" this added to the image ?

Thanks

@Turgon37
Copy link
Owner

@rhysxevans Hello, I did not reproduce the problem here

I'm using this env file

cat .env                                          
RELAY_MYNETWORKS="127.0.0.0/8 172.29.0.0/24"

and docker-compose file

version: '2'
services:
  smtp-relay:
    image: turgon37/smtp-relay
    container_name: smtp-relay
    hostname: smtp-relay
    restart: unless-stopped
    environment:
      - "RELAY_MYNETWORKS=${RELAY_MYNETWORKS}"

And run

source .env
docker-compose up -d

give me

docker-compose exec smtp-relay grep '^mynetworks' /etc/postfix/main.cf
mynetworks = 127.0.0.0/8 172.29.0.0/24

Are you using some other quote or escape character ?

@Turgon37 Turgon37 self-assigned this May 20, 2019
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

2 participants