|
|
|
|
|
by budafish
1963 days ago
|
|
Ive never quite managed to get the hang of setting up a dev container. I'ts a bit too tricky for me. I have resorted to using a throwaway dev container which mimics the local storage of packages. Hopefully someone find the below bash function useful. The only issue I have using this method is that I cant use VSCode to Debug, which I am hoping to find a nice solution for, but nothing yet. function python() {
docker run \
-it --rm \
--name python_$(pwd | sed 's#/home/##g' | sed 's#/#.#g')_$(date +"%H%M%S") \
-u $(id -u):$(id -g) \
-v "$(pwd)":"$(pwd)" \
-w "$(pwd)" \
-e PROJECT_ROOT="$(pwd)" \
-e PATH="$(pwd)/vendor/bin/:${PATH}" \
-e PYTHONUSERBASE="$(pwd)"/vendor \
-e PYTHONDONTWRITEBYTECODE=1 \
-e PIP_NO_CACHE_DIR=1 \
--net=host \
-h py-docker \
python:3-slim \
/bin/bash -c '/bin/bash --rcfile <(echo "PS1=\"[$(python --version)]:: \"") -i'
}
|
|