You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
quick Q&A tip, I'll answer it myself then close the issue.
Question: How would I preserve ipython history between docker-compose runs with the local setup?
When using docker-compose for local development, how would you preserve the ipython history between different runs of shellplus?
Answer: Just two lines in your local.yml
Extending the excellent setup that comes with cookiecutter-django, and adding this little change to the local.yml, is not hard. Make sure you've read these docs first
First do whatever you've been doing, to start your ipython shell inside of your docker-compose setup.
For example, I've got a project based on cookiecutter-django,
and this is how I was entering a shell for my project locally:
docker-compose run --rm django python manage.py shell_plus
I can add this to volumes section of my docker-compose YAML file:
volumes:
ipython_data_local: {}
Then in the section for the Python service:
services:
django:
volumes:
- .:/app # this was already here
- ipython_data_local:/root/.ipython/profile_default # persist ipython data, including ipython history#.........................`
And that'll do it :-)
Disclaimer
BY THE WAY: you only get certain benefits of Docker or Docker-Compose if you keep local and production almost identical. That's still recommended. production.yaml should work locally, for example. Even so, a local.yaml that is very productive and efficient can be a good idea, especially when you have contributors who might have trouble maintaining their own stable environment. So that's the intended use case of this.
Please do not open shells in production using this trick. Please interact responsibly :)
The text was updated successfully, but these errors were encountered:
Question: How would I preserve ipython history between docker-compose runs with the local setup?
When using
docker-compose
for local development, how would you preserve the ipython history between different runs ofshellplus
?Answer: Just two lines in your local.yml
Extending the excellent setup that comes with cookiecutter-django, and adding this little change to the
local.yml
, is not hard. Make sure you've read these docs firstThe quick change, as a
.diff
Explained in more detail
Copying from my gist here
First do whatever you've been doing, to start your ipython shell inside of your docker-compose setup.
For example, I've got a project based on cookiecutter-django,
and this is how I was entering a shell for my project locally:
So after doing that I checked where my ipython history might be.
Now that I have the path, I can use a volume to persist it using
the docker-compose YAML directives for this.
I can add this to
volumes
section of my docker-compose YAML file:Then in the section for the Python service:
And that'll do it :-)
Disclaimer
BY THE WAY: you only get certain benefits of Docker or Docker-Compose if you keep local and production almost identical. That's still recommended.
production.yaml
should work locally, for example. Even so, alocal.yaml
that is very productive and efficient can be a good idea, especially when you have contributors who might have trouble maintaining their own stable environment. So that's the intended use case of this.Please do not open shells in production using this trick. Please interact responsibly :)
The text was updated successfully, but these errors were encountered: