evertramos / docker-wordpress

Wordpress Docker container using SSL Certificates with LetsEncrypt
https://evertramos.github.io/docker-wordpress/
MIT License
484 stars 156 forks source link

Wordpress : Specifying Environment variables #25

Closed Tofdu31 closed 6 years ago

Tofdu31 commented 6 years ago

Hello Evert and nice job one more time!

Would it be possible to find a solution to add environment variables like bitnami images such as:

User and Site configuration

SMTP Configuration

This would be an example of User and Site and SMTP configuration using a GMail account:

Docker-compose.yml :

WORDPRESS_USERNAME= ${WORDPRESS_USERNAME}
WORDPRESS_PASSWORD= ${WORDPRESS_PASSWORD}
WORDPRESS_EMAIL= ${WORDPRESS_EMAIL}
WORDPRESS_FIRST_NAME= ${WORDPRESS_FIRST_NAME}
WORDPRESS_LAST_NAME= ${WORDPRESS_LAST_NAME}
WORDPRESS_BLOG_NAME= ${WORDPRESS_BLOG_NAME}
ALLOW_EMPTY_PASSWORD= ${ALLOW_EMPTY_PASSWORD}
SMTP_HOST= ${SMTP_HOST}
SMTP_PORT= ${SMTP_PORT}
SMTP_USER= ${SMTP_USER}
SMTP_PASSWORD= ${SMTP_PASSWORD}
SMTP_PROTOCOL= ${SMTP_PROTOCOL}

.env :

WORDPRESS_USERNAME=Put_your_name_login_of_user_wordpress_admin
WORDPRESS_PASSWORD=Put_your_password_of_user_wordpress_admin
WORDPRESS_EMAIL=Put_your_email_of_user_wordpress_admin
WORDPRESS_FIRST_NAME=Put_your_First_name_of_user_wordpress_admin
WORDPRESS_LAST_NAME=Put_your_Last_name_of_user_wordpress_admin
WORDPRESS_BLOG_NAME=Put_the_name_of_blog
ALLOW_EMPTY_PASSWORD=no
SMTP_HOST=Put_SMTP_SERVER
SMTP_PORT=Put_SMTP_PORT
SMTP_USER=Put_SMTP_SERVER_USER
SMTP_PASSWORD=Put_SMTP_SERVER_USER_PASSWORD
SMTP_PROTOCOL=Put_SMTP_SERVER_PROTOCOL

This is an idea that I hope will not give too much work :)

Thank

evertramos commented 6 years ago

Hello @Tofdu31

Thanks for the feedback.

I always rather work with the official images, but you could add this to the files.

Tofdu31 commented 6 years ago

I tried to add the lines but it does not work. I have an error:

ERROR: yaml.scanner.ScannerError: while scanning a simple key
  in "./docker-compose.yml", line 30, column 8
could not find expected ':'
  in "./docker-compose.yml", line 31, column 8

This is my docker-compose.yml

version: '3'

services:
   db:
     container_name: ${CONTAINER_DB_NAME}
     image: mariadb:latest
     restart: unless-stopped
     volumes:
        - ${DB_PATH}:/var/lib/mysql
     environment:
       MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
       MYSQL_DATABASE: ${MYSQL_DATABASE}
       MYSQL_USER: ${MYSQL_USER}
       MYSQL_PASSWORD: ${MYSQL_PASSWORD}

   wordpress:
     depends_on:
       - db
     container_name: ${CONTAINER_WP_NAME}
     image: wordpress:latest
     restart: unless-stopped
     volumes:
       - ${WP_CORE}:/var/www/html
       - ${WP_CONTENT}:/var/www/html/wp-content
       - ./conf.d/uploadsize.ini:/usr/local/etc/php/conf.d/uploadsize.ini
     environment:
       WORDPRESS_DB_HOST: ${CONTAINER_DB_NAME}:3306
       WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
       WORDPRESS_DB_USER: ${MYSQL_USER}
       WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
       WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX}
       WORDPRESS_USERNAME= ${WORDPRESS_USERNAME}
       WORDPRESS_PASSWORD= ${WORDPRESS_PASSWORD}
       WORDPRESS_EMAIL= ${WORDPRESS_EMAIL}
       WORDPRESS_FIRST_NAME= ${WORDPRESS_FIRST_NAME}
       WORDPRESS_LAST_NAME= ${WORDPRESS_LAST_NAME}
       WORDPRESS_BLOG_NAME= ${WORDPRESS_BLOG_NAME}
       ALLOW_EMPTY_PASSWORD= ${ALLOW_EMPTY_PASSWORD}
       SMTP_HOST= ${SMTP_HOST}
       SMTP_PORT= ${SMTP_PORT}
       SMTP_USER= ${SMTP_USER}
       SMTP_PASSWORD= ${SMTP_PASSWORD}
       SMTP_PROTOCOL= ${SMTP_PROTOCOL}
       VIRTUAL_HOST: ${DOMAINS}
       LETSENCRYPT_HOST: ${DOMAINS}
       LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
     logging:
       options:
         max-size: ${LOGGING_OPTIONS_MAX_SIZE:-200k}

#   wpcli:
#     image: tatemz/wp-cli
#     volumes:
#       - ${WP_CORE}:/var/www/html
#       - ${WP_CONTENT}:/var/www/html/wp-content
#     depends_on:
#       - db
#     entrypoint: wp

networks:
    default:
       external:
         name: ${NETWORK}
evertramos commented 6 years ago

Just update using : istead of =. Read your file carefully and check the details, but will work:

From:

       WORDPRESS_USERNAME= ${WORDPRESS_USERNAME}
       WORDPRESS_PASSWORD= ${WORDPRESS_PASSWORD}
       WORDPRESS_EMAIL= ${WORDPRESS_EMAIL}
       WORDPRESS_FIRST_NAME= ${WORDPRESS_FIRST_NAME}
       WORDPRESS_LAST_NAME= ${WORDPRESS_LAST_NAME}
       WORDPRESS_BLOG_NAME= ${WORDPRESS_BLOG_NAME}
       ALLOW_EMPTY_PASSWORD= ${ALLOW_EMPTY_PASSWORD}
       SMTP_HOST= ${SMTP_HOST}
       SMTP_PORT= ${SMTP_PORT}
       SMTP_USER= ${SMTP_USER}
       SMTP_PASSWORD= ${SMTP_PASSWORD}
       SMTP_PROTOCOL= ${SMTP_PROTOCOL}

To:

       WORDPRESS_USERNAME**:** ${WORDPRESS_USERNAME}
       WORDPRESS_PASSWORD: ${WORDPRESS_PASSWORD}
       WORDPRESS_EMAIL: ${WORDPRESS_EMAIL}
       etc...
Tofdu31 commented 6 years ago

arfff, but of course! So, I'm going to bed!