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

Docker setup is now working 👍 #13

Merged
merged 1 commit into from
Dec 18, 2023
Merged

Docker setup is now working 👍 #13

merged 1 commit into from
Dec 18, 2023

Conversation

testerez
Copy link
Contributor

@testerez testerez commented Dec 17, 2023

This PR is updating the code so that running WooCommerce in Docker is now fully functional.
When the plugin needs to query the local zaprite API, we can't use localhost because it would point to the docker's network. This is why I've setup the zaprite API url to http://host.docker.internal:3000 in docker-compose. This points to localhost on the host's network (your computer).
But when we want to redirect to a zaprite app page, then host.docker.internal would not work because it's loaded in your browser, not inside Docker. In that case we need it to be localhost.
This is why I changed ZAPRITE_PATH PHP constant to ZAPRITE_APP_URL and ZAPRITE_API_URL. Here is how they are setup in docker-compose:

      ZAPRITE_APP_URL: 'http://localhost:3000'
      ZAPRITE_API_URL: 'http://host.docker.internal:3000'

Note that ZAPRITE_API_URL defaults to ZAPRITE_APP_URL, so you still need to change a single variable when testing with Locals for example.

Anyway, now the Docker setup is fully working and I think is much easier when testing locally because:

  • Wordpress debug mode is already enabled
  • You don't need to manually seamlink the plugin directory to the right place
  • You don't need to manually change the zaprite URL and think about not adding this change to your commits
  • You don't need to install a third party app like Locals

All you need to do is: cd wordpress-docker && docker-compose up -d

@testerez testerez merged commit 71f0f58 into main Dec 18, 2023
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

Successfully merging this pull request may close these issues.

2 participants