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

Improve Docker Build Time #7

Closed
collinjackson93 opened this issue Dec 1, 2015 · 3 comments
Closed

Improve Docker Build Time #7

collinjackson93 opened this issue Dec 1, 2015 · 3 comments

Comments

@collinjackson93
Copy link

I know this image isn't exactly designed for development, but I find it a little cumbersome that the build process installs pip, wheel, mod_wsgi-express, and project dependencies every time there is a code change. Would it be possible to change the COPY . /app line to COPY ./requirements.txt ./app and then run COPY . /app after running mod_wsgi-docker-build? This would only invalidate the cache if the requirements list has changed. (See Dockerfile best practices here for an example)

@GrahamDumpleton
Copy link
Owner

Your suggestion unfortunately will not work in general case as the requirements.txt file may need to reference a local package that was copied in as part of your source code. So it gets complicated.

That mod_wsgi gets reinstalled is an issue I know of. It is actually installed as part of system wide Python as well and virtual environment chains off that and it is found, but when run out of system Python mod_wsgi wasn't picking up virtual environment correctly. I need to revisit it to work out how to fix that and then I can drop second installation of mod_wsgi. It only came up that that broke things in last week and I had to revert to doing the second installation.

Anyway, I haven't got a lot of time to explain in detail right now, or check my recipe works, as at training day, but presuming running Docker locally and how your Docker system is setup allows local file system mounting, the images are specifically set up to allow you to do.

docker build myapp .
docker run -v `pwd`:/app -p 8000:80 myapp --reload-on-changes

So you build it once to get an image with required dependencies, but then you actually mount the current directory into the container, overlaying and hiding what was copied in. You then ensure that --reload-on-changes option is also supplied to mod_wsgi-express and you can then make changes to the local file system to code files and your application will auto reload changes. This will allow you to do development.

See if you can get that going and if not tell me what OS you are using and how Docker was installed.

@collinjackson93
Copy link
Author

I kind of figured it wouldn't be that simple, but I figured I would suggest it on the off chance that it would work.

Thanks for the work around; I'll give it a shot.

@GrahamDumpleton
Copy link
Owner

The additional reinstall of pip and mod_wsgi shouldn't occur now. This is because the Python virtual environment has been done away with as it causes various problems. If you have stuff in 'requirements.txt', they will still be installed though.

The changes made are quite significant, but everything should still run okay. If you see any problems, especially with access permissions at run time, let me know ASAP.

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

2 participants