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 for local development? #332

Open
pwaring opened this issue May 31, 2023 · 13 comments
Open

Docker for local development? #332

pwaring opened this issue May 31, 2023 · 13 comments

Comments

@pwaring
Copy link

pwaring commented May 31, 2023

Would it be useful to have a Docker environment that could be used for local development, with everything pre-installed and with version numbers (e.g. for PHP) matching production? I've moved lots of existing bespoke projects into Docker so I think it would be doable.

@edent
Copy link
Collaborator

edent commented Jun 2, 2023

Sure! Go ahead and do it.

@pwaring
Copy link
Author

pwaring commented Jun 4, 2023

Okay, I'm working on this now.

@computamike
Copy link
Contributor

computamike commented Jul 23, 2023

I'm also looking at this - I was going to take a look at #333 - and I didn't want to install a load of stuff - and though that the docker approach might be cool (I use it at work for this sort of thing).

So far I have :

  • A Database set up script - that (i think) sets up the database correctly - there seems to be some warnings when executing
    image

  • A PHP / FPM based application that I think might work - currently getting composer vendor issues
    image

  • An NGINX wrapper - which passes php calls to FPM - but serves static files.

@computamike
Copy link
Contributor

@edent - One thing I'm not sure about : the code (and the CONTRIBUTING.md file) use composer to install dependancies - but there isn't a composer.json file included? unless the composer installation includes the version number, then won't there be the possibility that developers could have different version dependencies installed?

edent added a commit that referenced this issue Jul 23, 2023
@edent
Copy link
Collaborator

edent commented Jul 23, 2023

Thanks for the prompt @computamike - I've added the composer.json file

@pwaring
Copy link
Author

pwaring commented Jul 24, 2023

Just to add, I'm not working on this at the moment - I couldn't get the environment file to change the cache location and eventually I gave up in frustration (still not sure what the problem was).

@computamike
Copy link
Contributor

@pwaring - what was the issue with the cache location? at the moment I have caching working - but I'm guessing you wanted to map it somewhere else on the container so that it wasn't mapped back to the host file system?

@pwaring
Copy link
Author

pwaring commented Jul 28, 2023

@computamike Yes, I wanted the cache to use /tmp inside the container, that way it wouldn't create lots of files on the host (owned by root, one of the very annoying things about Docker). My understanding of Symfony is that setting APP_CACHE_DIR="/tmp" in the .env file should change the cache directory, but this didn't seem to work, and neither did manually setting $_ENV['APP_CACHE_DIR'], and stepping through with Xdebug suggested Symfony wasn't using it.

@computamike
Copy link
Contributor

@pwaring - I thought that might be it. Caching configuration is provided by bundle configuration - https://symfonycasts.com/screencast/symfony-fundamentals/bundle-config#play
image

  • I think if you mounted in a suitable config file there, then that might work - I'll give it a go.

@computamike
Copy link
Contributor

Hi @pwaring - I'd be interested in getting your opinion on my branch for adding docker support for local development - I'm putting together a guide for developers so it's not 100% yet.

https://github.com/computamike/openbenches.org/tree/Feature/docker-setup

I currently have the code volume mapped from a Windows drive (as opposed to running the code in wsl) and the page performance is not great - but I have read that storing the code like that can have performance issues.

@computamike
Copy link
Contributor

Just an update - I'm currently attempting to get Xdebug working - but from what I can see it's just a case of open the port, install Xdebug and set up some config and off you go...

@pwaring
Copy link
Author

pwaring commented Aug 11, 2023

@computamike If you want an example of how to get it working in VSCode, you can lift the config from a repository I work on:

https://github.com/phpdev-uk/slim-skeleton

Specifically the launch.json:

https://github.com/phpdev-uk/slim-skeleton/blob/main/.vscode/launch.json

Dockerfile:

https://github.com/phpdev-uk/slim-skeleton/blob/main/docker/Dockerfile

xdebug.ini:

https://github.com/phpdev-uk/slim-skeleton/blob/main/docker/php/xdebug.ini

It took me a long time to get this working as everything has to match - one minor difference and it won't work, plus you won't necessarily get a helpful error message as to why...

@computamike
Copy link
Contributor

@computamike If you want an example of how to get it working in VSCode, you can lift the config from a repository I work on:

https://github.com/phpdev-uk/slim-skeleton

Specifically the launch.json:

https://github.com/phpdev-uk/slim-skeleton/blob/main/.vscode/launch.json

Dockerfile:

https://github.com/phpdev-uk/slim-skeleton/blob/main/docker/Dockerfile

xdebug.ini:

https://github.com/phpdev-uk/slim-skeleton/blob/main/docker/php/xdebug.ini

It took me a long time to get this working as everything has to match - one minor difference and it won't work, plus you won't necessarily get a helpful error message as to why...

Thanks - I got it working last night - then the cachinf stopped working... I open port 9003 on the defender firewall - but I'm not sure I needed to do that. I'll make sure what i have looks good compared to what you've done - probably tonight.

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

3 participants