Created
January 9, 2020 07:00
-
-
Save jthorniley/fba81c62a9d45c723777c7205ff96481 to your computer and use it in GitHub Desktop.
Install Poetry in Docker devcontainer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USER vscode | |
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - --version=0.12.17 | |
ENV PATH "/home/vscode/.poetry/bin:$PATH" |
You can set "postCreateCommand": "poetry update"
in .devcontainer/devcontainer.json
.
You could also set the variable in the local poetry config file poetry.toml
:
[virtualenvs]
in-project = true
Or using the CLI:
poetry config virtualenvs.in-project true --local
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bearrito
What I do is I set the config to create the virtualenv in the project directory, which also makes it no longer ephemeral with the container.
You can accomplish this using
RUN /home/vscode/.local/bin/poetry config virtualenvs.in-project true
. I just find it easier for my workflow to have the environment in project tree.poetry update
is then called in the terminal on vscode. As for dealing with the interpreter and whatnot, because the virtualenv is inside the project, there is a clear path for it in/workspace/vscode/[project]/.venv/bin/[util]
which you can set in your.vscode/settings.json
or in.devcontainer/devcontainer.json
.I've seen people set
virtualenvs.create false
and then useRUN /home/vscode/.local/bin/poetry install
in theDockerfile
too. I would imagine that would get rid of the need to separately set the location of your paths. If you want to avoid having to specify all of the path for each time you runpoetry
in yourDockerfile
, I believe you should be able to accomplish that via multi-stage builds, but I am a creature of habit and never tried it.