visiblevc / wordpress-starter

A slightly less shitty wordpress development workflow
688 stars 167 forks source link

URL_REPLACE not working #168

Closed abeardsley-vertex closed 4 years ago

abeardsley-vertex commented 4 years ago

Overview

I am migrating development from vvv to this. But when running docker compose up on a first run, the URL_REPLACE function does not seem to work. Is it in the wrong place in my docker-compose.yml?

If I log into the docker container itself I can run wp search-replace and it will work fine.

There is a database file that is restored as part of the first run (this is obvious I suppose), is the database restore happening after the url_replace maybe?

The only weird thing I can think of that I'm doing is attaching the entire wp-content folder, not just a single plugin or something.

In the docker-compose output, there is this. Is it possible that the version numbers here are trying to tell me something or are the source of the problem?

wordpress_1   | ==> Importing /data/database.sql (this might take a while)...
wordpress_1   | Success: Imported from '/data/database.sql'.
wordpress_1   | ==> Updating database...
wordpress_1   | Success: WordPress database upgraded successfully
wordpress_1   |          from db version 44719 to 45805.

Win 10 x64

Client: Docker Engine - Community
 Version:           19.03.4
 API version:       1.40
 Go version:        go1.12.10
 Git commit:        9013bf5
 Built:             Thu Oct 17 23:44:48 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.4
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.10
  Git commit:       9013bf5
  Built:            Thu Oct 17 23:50:38 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

docker-compose.yml

version: '3'
services:
    wordpress:
        image: visiblevc/wordpress

        # required for mounting bindfs
        cap_add:
            - SYS_ADMIN
        devices:
            - /dev/fuse
        # required on certain cloud hosts
        security_opt:
            - apparmor:unconfined

        ports:
            - 8080:80
            - 443:443
        volumes:
            - ./data:/data
            - ./scripts:/docker-entrypoint-initwp.d
            - ./wp-content:/app/wp-content
        environment:
            URL_REPLACE: http://localhost:8080
            DB_NAME: wordpress
            DB_PASS: root
            PLUGINS: >-
                academic-bloggers-toolkit
                co-authors-plus
                [WP-API]https://github.com/WP-API/WP-API/archive/master.zip
    db:
        image: mariadb:10 #mariadb:10 or mysql:5.7
        volumes:
            - data:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: root

    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        ports:
            - 22222:80

volumes:
    data:

Project structure

/data
  /database.sql
/wp-content
  /plugins
    /academic-bloggers-toolkit
    /co-authors-plus
    /woocommerce
    /woocommerce-dynamic-pricing
    /woocommerce-gateway-authorize-net-cim
    /woocommerce-subscriptions
    /WP-API
    /mycustomplugin
  /themes
    /storefront
    /twentynineteen
    /twentyseventeen
    /twentysixteen
    /twentytwenty

docker-compose up output

> docker-compose up                                                 
Creating network "my-project-wp_default" with the default driver
Creating volume "my-project-wp_data" with default driver
Creating my-project-wp_wordpress_1  ... done                                                                          Creating my-project-wp_db_1         ... done                                                                          Creating my-project-wp_phpmyadmin_1 ... done                                                                          Attaching to my-project-wp_db_1, my-project-wp_phpmyadmin_1, my-project-wp_wordpress_1
db_1          | 2019-12-11 00:33:00+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.10+maria~bionic started.
phpmyadmin_1  | phpMyAdmin not found in /var/www/html - copying now...
wordpress_1   | ======================================================================
wordpress_1   |                     Begin WordPress Installation
wordpress_1   | ======================================================================
wordpress_1   | find: unknown predicate `-t'
phpmyadmin_1  | Complete! phpMyAdmin has been successfully copied to /var/www/html
phpmyadmin_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.25.0.4. Set the 'ServerName' directive globally to suppress this message
db_1          | 2019-12-11 00:33:01+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
phpmyadmin_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.25.0.4. Set the 'ServerName' directive globally to suppress this message
db_1          | 2019-12-11 00:33:01+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.10+maria~bionic started.
phpmyadmin_1  | [Wed Dec 11 00:33:01.107816 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.2.25 configured -- resuming normal operations
phpmyadmin_1  | [Wed Dec 11 00:33:01.108171 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
db_1          | 2019-12-11 00:33:01+00:00 [Note] [Entrypoint]: Initializing database files
wordpress_1   | ==> Downloading WordPress
db_1          |
db_1          |
db_1          | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
db_1          | To do so, start the server, then issue the following commands:
db_1          |
db_1          | '/usr/bin/mysqladmin' -u root password 'new-password'
db_1          | '/usr/bin/mysqladmin' -u root -h  password 'new-password'
db_1          |
db_1          | Alternatively you can run:
db_1          | '/usr/bin/mysql_secure_installation'
db_1          |
db_1          | which will also give you the option of removing the test
db_1          | databases and anonymous user created by default.  This is
db_1          | strongly recommended for production servers.
db_1          |
db_1          | See the MariaDB Knowledgebase at http://mariadb.com/kb or the
db_1          | MySQL manual for more instructions.
db_1          |
db_1          | Please report any problems at http://mariadb.org/jira
db_1          |
db_1          | The latest information about MariaDB is available at http://mariadb.org/.
db_1          | You can find additional information about the MySQL part at:
db_1          | http://dev.mysql.com
db_1          | Consider joining MariaDB's strong and vibrant community:
db_1          | https://mariadb.org/get-involved/
db_1          |
db_1          | 2019-12-11 00:33:03+00:00 [Note] [Entrypoint]: Database files initialized
db_1          | 2019-12-11 00:33:03+00:00 [Note] [Entrypoint]: Starting temporary server
db_1          | 2019-12-11 00:33:03+00:00 [Note] [Entrypoint]: Waiting for server startup
db_1          | 2019-12-11  0:33:03 0 [Note] mysqld (mysqld 10.4.10-MariaDB-1:10.4.10+maria~bionic) starting as process 121 ...
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Using Linux native AIO
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Uses event mutexes
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Number of pools: 1
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Using SSE2 crc32 instructions
db_1          | 2019-12-11  0:33:03 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Completed initialization of buffer pool
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: 10.4.10 started; log sequence number 139827; transaction id 21
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1          | 2019-12-11  0:33:03 0 [Note] Plugin 'FEEDBACK' is disabled.
db_1          | 2019-12-11  0:33:03 0 [Warning] 'user' entry 'root@8df9f9607aa3' ignored in --skip-name-resolve mode.
db_1          | 2019-12-11  0:33:03 0 [Warning] 'user' entry '@8df9f9607aa3' ignored in --skip-name-resolve mode.
db_1          | 2019-12-11  0:33:03 0 [Warning] 'proxies_priv' entry '@% root@8df9f9607aa3' ignored in --skip-name-resolve mode.
db_1          | 2019-12-11  0:33:03 0 [Note] InnoDB: Buffer pool(s) load completed at 191211  0:33:03
db_1          | 2019-12-11  0:33:03 0 [Note] Reading of all Master_info entries succeeded
db_1          | 2019-12-11  0:33:03 0 [Note] Added new Master_info '' to hash table
db_1          | 2019-12-11  0:33:03 0 [Note] mysqld: ready for connections.
db_1          | Version: '10.4.10-MariaDB-1:10.4.10+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
db_1          | 2019-12-11 00:33:04+00:00 [Note] [Entrypoint]: Temporary server started.
db_1          | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
wordpress_1   |          Downloading WordPress 5.3 (en_US)...
wordpress_1   |          md5 hash verified: c2a23451e943a1244a7ccca909891df8
wordpress_1   | Success: WordPress downloaded.
wordpress_1   | ==> Waiting for MySQL to initialize...
db_1          | 2019-12-11  0:33:22 10 [Warning] 'proxies_priv' entry '@% root@8df9f9607aa3' ignored in --skip-name-resolve mode.
db_1          |
db_1          | 2019-12-11 00:33:22+00:00 [Note] [Entrypoint]: Stopping temporary server
db_1          | 2019-12-11  0:33:22 0 [Note] mysqld (initiated by: root[root] @ localhost []): Normal shutdown
db_1          | 2019-12-11  0:33:22 0 [Note] Event Scheduler: Purging the queue. 0 events
db_1          | 2019-12-11  0:33:22 0 [Note] InnoDB: FTS optimize thread exiting.
db_1          | 2019-12-11  0:33:22 0 [Note] InnoDB: Starting shutdown...
db_1          | 2019-12-11  0:33:22 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
db_1          | 2019-12-11  0:33:22 0 [Note] InnoDB: Buffer pool(s) dump completed at 191211  0:33:22
db_1          | 2019-12-11  0:33:23 0 [Note] InnoDB: Shutdown completed; log sequence number 20285019; transaction id 14620
db_1          | 2019-12-11  0:33:23 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
db_1          | 2019-12-11  0:33:23 0 [Note] mysqld: Shutdown complete
db_1          |
db_1          | 2019-12-11 00:33:24+00:00 [Note] [Entrypoint]: Temporary server stopped
db_1          |
db_1          | 2019-12-11 00:33:24+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
db_1          |
db_1          | 2019-12-11  0:33:24 0 [Note] mysqld (mysqld 10.4.10-MariaDB-1:10.4.10+maria~bionic) starting as process 1 ...
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Using Linux native AIO
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Uses event mutexes
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Number of pools: 1
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Using SSE2 crc32 instructions
db_1          | 2019-12-11  0:33:24 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Completed initialization of buffer pool
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: 10.4.10 started; log sequence number 20285019; transaction id 14620
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1          | 2019-12-11  0:33:24 0 [Note] Plugin 'FEEDBACK' is disabled.
db_1          | 2019-12-11  0:33:24 0 [Note] Server socket created on IP: '::'.
db_1          | 2019-12-11  0:33:24 0 [Warning] 'proxies_priv' entry '@% root@8df9f9607aa3' ignored in --skip-name-resolve mode.
db_1          | 2019-12-11  0:33:24 0 [Note] Reading of all Master_info entries succeeded
db_1          | 2019-12-11  0:33:24 0 [Note] Added new Master_info '' to hash table
db_1          | 2019-12-11  0:33:24 0 [Note] mysqld: ready for connections.
db_1          | Version: '10.4.10-MariaDB-1:10.4.10+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
db_1          | 2019-12-11  0:33:24 0 [Note] InnoDB: Buffer pool(s) load completed at 191211  0:33:24
wordpress_1   | ==> Configuring WordPress
wordpress_1   | Success: Generated 'wp-config.php' file.
wordpress_1   | ==> Checking database
wordpress_1   | Success: Database created.
wordpress_1   | Success: WordPress installed successfully.
wordpress_1   | ==> Importing /data/database.sql (this might take a while)...
wordpress_1   | Success: Imported from '/data/database.sql'.
wordpress_1   | ==> Updating database...
wordpress_1   | Success: WordPress database upgraded successfully
wordpress_1   |          from db version 44719 to 45805.
wordpress_1   | ==> Checking themes
wordpress_1   | Success: Switched to 'Twenty Twenty' theme.
wordpress_1   | ==> Checking plugins
wordpress_1   | Warning: The
wordpress_1   |          'https://github.com/WP-API/WP-API/archive/master.zip' plugin
wordpress_1   |          could not be found.
wordpress_1   |   Error: No plugins activated.
wordpress_1   |          Plugin 'co-authors-plus' activated.
wordpress_1   | Success: Activated 1 of 1 plugins.
wordpress_1   |          Plugin 'academic-bloggers-toolkit' activated.
wordpress_1   | Success: Activated 1 of 1 plugins.
wordpress_1   | ==> Finalizing
wordpress_1   | Success: Rewrite structure set.
wordpress_1   | Success: Rewrite rules flushed.
wordpress_1   | ==> Executing user init scripts
wordpress_1   | /usr/bin/env: 'bash\r': No such file or directory
wordpress_1   | ======================================================================
wordpress_1   |                   WordPress Installation Complete!
wordpress_1   | ======================================================================
wordpress_1   | [Wed Dec 11 00:34:22.817023 2019] [mpm_prefork:notice] [pid 128] AH00163: Apache/2.4.38 (Debian) PHP/7.3.11 configured -- resuming normal operations
wordpress_1   | [Wed Dec 11 00:34:22.817077 2019] [core:notice] [pid 128] AH00094: Command line: 'apache2 -D FOREGROUND'
dsifford commented 4 years ago

This is strange for a number of reasons.

I'm also seeing near the bottom of your logs you're getting an error with one of your init scripts...

wordpress_1   | /usr/bin/env: 'bash\r': No such file or directory

That's extremely irregular. /usr/bin/env is most certainly available in the image.


But anyway, to address your comments...

There is a database file that is restored as part of the first run (this is obvious I suppose), is the database restore happening after the url_replace maybe?

Nope, it's in the correct order. See below...

https://github.com/visiblevc/wordpress-starter/blob/0b45d216f8e3fd503c24c48ac476b7ee023aba74/run.sh#L192-L207

The only weird thing I can think of that I'm doing is attaching the entire wp-content folder, not just a single plugin or something

This shouldn't be a problem.

In the docker-compose output, there is this. Is it possible that the version numbers here are trying to tell me something or are the source of the problem?

Nope, this just updates the wordpress tables to the latest version compatible with your installed wordpress version. Numbers don't really matter and aren't important really to note.


Can you try again? Do a full docker-compose down -v and clean up the example stuff from the compose file that you aren't using and lets go from there.

abeardsley-vertex commented 4 years ago

Confession time...I was editing the wrong docker-compose when trying to get url_replace to work.

However, in my troubleshooting I did find where the wordpress_1 | /usr/bin/env: 'bash\r': No such file or directory error was coming from.

Commenting out - ./scripts:/docker-entrypoint-initwp.d solved that one. I suppose it is because docker-entrypoint-initwp.d does not exist? I had that in the docker-compose from the original git example.

Hopefully that helps and I have not completely wasted your time. Thank you for the prompt reply!

dsifford commented 4 years ago

No worries. Glad to hear you got it sorted out!