Skip to content

Instantly share code, notes, and snippets.

@pgroot91
Forked from pjaudiomv/docker-compose.yml
Created April 17, 2025 00:47
Show Gist options
  • Save pgroot91/038f31f91f347c529db30af7b7c3b9f7 to your computer and use it in GitHub Desktop.
Save pgroot91/038f31f91f347c529db30af7b7c3b9f7 to your computer and use it in GitHub Desktop.

Revisions

  1. @pjaudiomv pjaudiomv created this gist Jun 23, 2024.
    79 changes: 79 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    services:
    wordpress:
    depends_on:
    - db
    - mailpit
    image: wordpress:6.5.3-php8.3-apache
    restart: always
    ports:
    - 8080:80
    - 7443:443
    environment:
    WORDPRESS_DEBUG: true
    WORDPRESS_DB_HOST: db:3306
    WORDPRESS_DB_USER: wordpress
    WORDPRESS_DB_PASSWORD: wordpress
    WORDPRESS_DB_NAME: wordpress
    WORDPRESS_SMTP_HOST: mailpit
    WORDPRESS_SMTP_PORT: 1025
    SMTP_HOSTNAME: mailpit
    SMTP_PORT: "1025"
    SMTP_USER: [email protected]
    SMTP_FROM: [email protected]
    WORDPRESS_CONFIG_EXTRA: |
    // SMTP Settings
    require_once( ABSPATH .'wp-includes/plugin.php' );
    add_action( 'phpmailer_init', 'mail_smtp' );
    function mail_smtp( $$phpmailer ) {
    $$phpmailer->isSMTP();
    $$phpmailer->Host = getenv('SMTP_HOSTNAME');
    $$phpmailer->Port = getenv('SMTP_PORT');
    $$phpmailer->From = getenv('SMTP_FROM');
    $$phpmailer->FromName = getenv('SMTP_FROM_NAME');
    // Additional settings
    $$phpmailer->SMTPAuth = false;
    $$phpmailer->SMTPSecure = "";
    $$phpmailer->SMTPAutoTLS = false;
    // Filter out client message body and output debug info to the logs
    // NOTE: Log level must be set to '2' or higher in order for the filter to work
    $$phpmailer->SMTPDebug = 2;
    $$phpmailer->Debugoutput = function($$str) {
    static $$logging = true;
    if ($$logging === false && strpos($$str, 'SERVER -> CLIENT') !== false) {
    $$logging = true;
    }
    if ($$logging) {
    error_log("SMTP " . "$$str");
    }
    if (strpos($$str, 'SERVER -> CLIENT: 354') !== false) {
    $$logging = false;
    }
    };
    }
    // Prevent Wordpress from overriding the SMTP FROM address (Office 365 compatibility)
    add_filter( 'wp_mail_from', function( $$email ) {
    return $$_ENV["SMTP_FROM"];
    });
    volumes:
    - ../:/var/www/html/wp-content/plugins
    - ./logs/:/var/log/apache2

    db:
    image: mariadb:10.11
    restart: always
    ports:
    - 3306:3306
    environment:
    MARIADB_ROOT_PASSWORD: somewordpress
    MARIADB_DATABASE: wordpress
    MARIADB_USER: wordpress
    MARIADB_PASSWORD: wordpress

    mailpit:
    image: axllent/mailpit
    ports:
    - "1025:1025"
    - "8025:8025"