|
1 | | -# vim-python-docker-template |
| 1 | +# vim-python-docker-template |
| 2 | + |
| 3 | +This is a template for python-based projects. Many DS/ML workflows require |
| 4 | +hardware-specific platforms in detailed OS-level libraries and python |
| 5 | +dependencies. In some cases, it is useful to perform code editing in the same |
| 6 | +environment in which applications are run. This template can help vim users to |
| 7 | +run vim-ide with the same project environment on a local or remote machine. |
| 8 | +Please, feel free to massage everything in the template as you wish. |
| 9 | + |
| 10 | +Vim is configured in a modern style and supports almost all ide-specific |
| 11 | +features. Please see `.vimrc.dist` for reference. |
| 12 | + |
| 13 | +Tested under versions: |
| 14 | + |
| 15 | +- docker `27.3.1` |
| 16 | +- buildx `2.32.1` |
| 17 | +- compose `2.32.1` |
| 18 | + |
| 19 | +## How to use template |
| 20 | + |
| 21 | +First, initialize the compose env, pick the required OS packages, and set the |
| 22 | +python/poetry versions: |
| 23 | + |
| 24 | +```bash |
| 25 | +cp .env.dist .env |
| 26 | +vim .env |
| 27 | +``` |
| 28 | + |
| 29 | +Edit the poetry configuration file to manage python project-specific things and |
| 30 | +dependencies: |
| 31 | + |
| 32 | +```bash |
| 33 | +vim pyproject.toml |
| 34 | +``` |
| 35 | + |
| 36 | +Build python base image with poetry layer and create a lock file: |
| 37 | + |
| 38 | +```bash |
| 39 | +docker compose build poetry |
| 40 | +docker compose run --rm poetry lock --no-cache |
| 41 | +git add poetry.lock |
| 42 | +``` |
| 43 | + |
| 44 | +Second, create the image with python dependencies and vim-ide on top of it: |
| 45 | + |
| 46 | +```bash |
| 47 | +cp .vimrc.dist .vimrc |
| 48 | +cp .coc-settings.json.dist .coc-settings.json |
| 49 | +git config --local user.name "John Doe" |
| 50 | +git config --local user.email johndoe@example.com |
| 51 | +docker compose build vim-ide |
| 52 | +``` |
| 53 | + |
| 54 | +Launch vim and do some development inside the container: |
| 55 | + |
| 56 | +```bash |
| 57 | +docker compose run --rm vim-ide |
| 58 | +``` |
| 59 | + |
| 60 | +Don't forget to update the lock file: |
| 61 | + |
| 62 | +```bash |
| 63 | +docker compose run --rm poetry lock --no-cache |
| 64 | +``` |
| 65 | + |
| 66 | +Finally, build and run your application: |
| 67 | + |
| 68 | +```bash |
| 69 | +docker compose build app |
| 70 | +docker compose run --rm app |
| 71 | +``` |
| 72 | + |
| 73 | +If desired, you can run Jupyter on top of the application: |
| 74 | + |
| 75 | +```bash |
| 76 | +docker compose build jupyterlab |
| 77 | +docker compose run --rm --service-ports jupyterlab |
| 78 | +# accsess http://127.0.0.1:8888/lab?token=<.env token> |
| 79 | +``` |
| 80 | + |
0 commit comments