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

Run wp-cli commands as a part of Docker setup #110

Open
abhinayagarwal opened this issue Jan 19, 2024 · 0 comments
Open

Run wp-cli commands as a part of Docker setup #110

abhinayagarwal opened this issue Jan 19, 2024 · 0 comments

Comments

@abhinayagarwal
Copy link

I am trying to automate setting up my wordpress site using this docker-compose configuration.

This is the manual step which I do atm:

docker exec -it myapp-wordpress bash

and then inside the docker container:

wp core install --url=myapp.local --title="MyApp" --admin_user=admin --admin_password=secret [email protected]
# other wp commands

This works fine and I am able to access the site. I would like to automate this step along with a few other wp commands. My target is to keep these commands in a shell script and then run it from a Dockerfile via CMD.

Currently, I am just executing wp core install as a part of the Dockerfile to test but executing it as a part of Docker messes up some configuration which I am unable to figure out:

...
RUN mkdir -p /var/www/.wp-cli/cache && chown www-data:www-data /var/www/.wp-cli/cache

# sleep is required so that MySQL is ready to accept requests
CMD sleep 10 && wp core install --url=myapp.local --title="MyApp" --admin_user=admin --admin_password=secret [email protected] && tail -f /dev/null

I start getting 502 while trying to access the website. On the terminal, I can see this:

myapp-wordpress  | Success: WordPress installed successfully.
myapp-nginx      | 2024/01/19 08:19:12 [error] 36#36: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: myapp.local, request: "GET /wp/wp-admin/ HTTP/2.0", upstream: "fastcgi://172.19.0.4:9000", host: "myapp.local"

Any pointers on how to execute these wp commands as a part of docker compose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant