-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support output dimensions with local dev #31
Conversation
de053c5
to
0871eaa
Compare
…yes, this is confusing)
* Docker: Add docker volume so that you can edit the files locally * Fix memcache This part is untesed in production. I am not sure what port is used there. * Specify compatible version of memcache memcache 8.0 requires php 8.x, so we need to use a version compatible with our php7.4 ( https://pecl.php.net/package/memcache ) * add .dockerignore * typo * Share dev local dev filesystem with container * Add MSHOTS_MEMCACHE_HOST environment variable to control memcache server inside container * update package-lock.json * build container successfully if the requested user already exists * Support "simple" docker container alongside shared local filesystem version using `npm run config:dev` command * Add note about replacement mshots_ctl.sh stop * Add docker image prune to troubleshooting * separate concerns better in package.json scripts * Remove docker-compose.yml from git so it doesn't show up in git diffs * fix npm start script * Enable chromium sandbox outside a container * remove unnecessary directory limitation Co-authored-by: Julian de Bhal <[email protected]>
Local mShots is working! 🥳 I installed this in One hickup when I ran
Problem solved after following those instructions there to add I was able to successfully generate screenshots for : and and As we discussed in our call here were my newbie points of confusion: To get theme url and generate a screenshot from the running local mShots:
I looked for the generated screenshots in Great job @deBhal cc: @ramonjd Hope this helps with handholding ✋ |
The folder will be relative to your mshots checkout - |
0871eaa
to
89d2eca
Compare
Ignore that picture, example.com is supposed to be a 404 😆 I'm not seeing any errors in I've also tried bashing into the running container and starting the service manually just to make sure it's actually started. It is. So I'm a bit confused. Edit: I also ran |
@p-jackson and I looked into those issues and they're related to sandboxing the public-api endpoint. For now, please just unsandbox any sites you want to point mshots at. It would be really nice to get the dev setup working with sandboxed sites, but we'll punt that feature to a subsequent PR |
This is amazing. Install and boot worked first time for me. I decided to run Calypso locally and set the mshots URL to run through Looks fantastic. The only curiosity was that I had to remove URL encoding ( So it renders this But not this I'm not sure why. The rawurldecode is there 🦐 |
This is testing nicely for me too, @deBhal, but I can also recreate the issue @ramonjd mentioned above. I wonder if it's a difference between how Apache behaves in our local dev containers, and nginx in prod? I suppose in that second URL (http://127.0.0.1:8000/mshots/v1/https%3A%2F%2Fpublic-api.wordpress.com%2Frest%2Fv1%2Ftemplate%2Fdemo%2Frockfield%2Frockfield%3Ffont_headings%3DPlayfair%2520Display%26font_base%3DFira%2520Sans%26site_title%3DRockfield%26viewport_height%3D700%26language%3Den?vpw=1600&vph=1600&w=600&h=600&count=1) we're encoding too much of it? We might only want to encode the query string of the site we're taking a screenshot of, and not the entire url (which appears to be what's happening here in Gutenboarding) and in the page layout picker here). Instead of URI encoding the target url in those places, maybe it'd be better to sanitize? Or, alternately, figure out how to get Apache to behave as we'd expect with the additional encoding? |
Yep, you were totally right. I turned on all the logging and found:
After that it was just a matter of learning a new sed trick to get around an old apache bug ;) |
Brilliant! |
I've created Automattic/wp-calypso#51261 to test this PR, and everything is looking great, so I think I'm ready to merge now and close the three branches this one swallowed (#18, #20 and #22) I'll just hold off in case systems would like an opportunity to review it in a nice convenient PR format. |
Congrats @deBhal ! This was an epic work and getting this submitted to systems is a huge milestone! Many props to you and to everyone who helped review and provide feedback. 🎉 |
Update: Barry explicitly said "merge the changes", so I've done that, and I'll just hold off on deleting the branch until the changes are merged instead. |
This PR combines #18 & #22. Each of those PRs "works" as a standalone PR, and we can merge either of them, but in this case each PR makes the other easier to test, so in this case it's arguably easier to review the one big diff rather than the two little ones independantly.
As a reviewer please use the PR(s) that you feel most comfortable with, including commenting/approving whatever you feel comfortable with. I'll keep the three branches in sync and the other two branches operating independantly until one of them gets merged and everything gets simple again, so you can approve just one of the bases if you like.There were a number of little fixes required after combining these branches together, and cleaning up the git history doesn't seem like a good use of time unless someone cares. If you'd like to review/approve one of the source branches separately let me know and happy to cherry-pick all the changes into the two source branches.
Testing Instructions
npm install
npm start
docker-compose logs
to watch for the output if you prefer)You can find examples of the URLs we care about on the
https://wordpress.com/new/style
page.https://wordpress.com/new/style
This will get you a url like:
https://s0.wp.com/mshots/v1/https%3A%2F%2Fpublic-api.wordpress.com%2Frest%2Fv1%2Ftemplate%2Fdemo%2Fmaywood%2Fmaywood%3Ffont_headings%3DPlayfair%2520Display%26font_base%3DFira%2520Sans%26site_title%3DMaywood%26viewport_height%3D700%26language%3Dde?vpw=1600&vph=1600&w=600&h=600&count=1
Replace
https://s0.wp.com/
with127.0.0.1:8000/
to point it at your dev server and add the new?screen_height=3600
param to mshots itself, giving us a url like:127.0.0.1:8000/mshots/v1/https%3A%2F%2Fpublic-api.wordpress.com%2Frest%2Fv1%2Ftemplate%2Fdemo%2Fmaywood%2Fmaywood%3Ffont_headings%3DPlayfair%2520Display%26font_base%3DFira%2520Sans%26site_title%3DMaywood%26viewport_height%3D700%26language%3Dde?vpw=1600&vph=1600&w=600&h=600&count=1&screen_height=3600
You can also point calypso at it by editing
wp-calypso/client/landing/gutenboarding/components/mshots-image/index.tsx
:`const mshotsUrl = 'http://127.0.0.1:8000/mshots/v1/';
The problem with this approach is that you'll most likely swamp your little dev server and get a bunch of timeouts resulting in 404s. Then mshots will cache those 404 images and return them until you tell it to try again by adding
&requeue=true
to the query, e.g.: http://127.0.0.1:8000/mshots/v1/https%3A%2F%2Fpublic-api.wordpress.com%2Frest%2Fv1%2Ftemplate%2Fdemo%2Fmaywood%2Fmaywood%3Ffont_headings%3DPlayfair%2520Display%26font_base%3DFira%2520Sans%26site_title%3DMaywood%26viewport_height%3D700%26language%3Dde?vpw=1600&vph=1600&w=600&h=600&count=1&screen_height=3600&requeue=trueOnce you requeue the individual images in a separate tab you can refresh the design page to see them there.