09 may
Hokay, so. The last few weeks were devoured by a11y updates and brushing up on PHP. I’m still doing quite a bit of PHP brush up via treehouse, but we’re at the point where we need to start testing out what might work going forward with the website updates, so now it’s time to make notes on what I’m doing.
WP in docker
Y’all know how much I love docker, so it’s no surprise that I’m testing migration of our stack in docker.
Found a little gem of an article on building WP/db in docker: Local WordPress Development with Docker: 3 Easy Steps. And this worked! Besides needing to making sure the MySQL and WP admin passwords matched, everything is up and running, and now I get to install WordPress and see what breaks.
Theoretically, everything that is WP-related in roots-ualib
should still work on PHP 7.2. It’s the outside apps/APIs that are the issue. I’m testing this theory in docker, but I feel like I’ve already tested it locally? My machine runs php 7.1, so wouldn’t my local WordPress install have issues if there was something wrong? It will be good to have the whole thing in isolation, though, just to be sure.
install
Once the installation screen was up, I ran through basic wp install. Went ahead and upgraded WP to version 5.2 and updated all the themes that needed updating. Just want to get everything out of the way before dumping the roots-ualib
theme and content in here.
clone theme
Accessed the wp files via docker exec -it wordpress-docker_my-wp_1
, navigated to wp-content/themes
and tried to git clone the repo… but this container doesn’t have git. Duh. So, apt-get install git
. Unable to locate package git…
Googling revealed that the apt repository hadn’t been updated yet. So I did that! apt-get update && apt-get upgrade -y
then installed git apt-get install git
. Also realized vim probably wasn’t installed, so I fixed that, too: apt-get install vim
. Now to clone!
set up theme
I forgot about all the nonsense needed to run this damn theme. Gotta install node, bower, and grunt.
- node:
curl -sL https://deb.nodesource.com/setup_12.x | bash -
thenapt-get install -y nodejs
cd back to roots-ualib
directory to install dependencies:
npm install -g grunt-cli
npm install -g bower
-
npm install
for package-json dependencies -
bower install --allow-root
for bower dependencies (since I’m root user, need the root flag there)
Obviously, all of these install steps need to be moved to the docker commands somehow becuase this is dumb. I know a Dockerfile can handle installing stuff, but I’m using docker-compose here… there’s gotta be a way, right?
messed it up
Surprise, surprise… something I did messed everything up! Which is why we test this shit in docker.
Using docker-compose logs -f
, I can see the apache logs as they run. It’s indicating that it’s trying to reach the superGlobalPHP
file on our server, which it of course can’t do from inside a container. I figured this would be an issue somewhere, but I really thought there would be more of a separation of concerns… time to debug.
errors
The fatal error was at the top of functions.php
where it includes the API/app stuff for the development environment. I commented it out to see what would happen. The page and theme are both loading now, but none of the apps are working, which is what I expected would happen once I commented that stuff out.
I really thought these apps were only pulling the JSON data from the API, but I guess they must be pulling it in from the superGlobalPHP at some point… investigation time! I was right: a CORS/wp-nonce situation is blocking the HTTP request from our APIs. All is well!
helpful articles
- How to use docker compose
- Docker docs: Get started with Docker Compose
-
Stack Overflow: using a Dockerfile with docker compose
- I assume I need this in order to install dependencies like git, node, etc… but I don’t need/want to install a full linux distro??
10 may
Today has been a journey of building a LAMP stack for the testing the apps/API. I watched a few videos and tried out a few pre-built images, but the thing that ended up working best for me was this article: How to create a docker-based LAMP stack using docker-compose on Ubuntu 18.04 Bionic Beaver Linux
Now getting everything set up in there is going to be the trick. I believe I need to:
- make copies of
superGlobalPHP
andwebapps
directories for the docker containers- out of the box, I set up the Dockerfile to run a simple index.php that displays the
phpinfo()
- needs to run at least one of the many apps we need to test
- I’ve not actually looked at any of those files, so I’m unsure if they have index files or not… hopefully yes!
- out of the box, I set up the Dockerfile to run a simple index.php that displays the
- seed the docker database with current data
- jennifer gave me instructions on dumping data out of our databases
- she also gave me instructions on getting that into a new database
- now I just need to apply that to a docker environment… the mariadb container should have a command line, so I think I can handle that
- make sure everything is connected and logging errors so I can start to debug this mother