Hacker News new | past | comments | ask | show | jobs | submit login

How do you handle debugging? like from vs code?



I personally debug with logs, but what you are asking seems possible:

- Debug containerized apps: https://code.visualstudio.com/docs/containers/debug-common

- Debug Python within a container: https://code.visualstudio.com/docs/containers/debug-python

You can apparently develop directly inside a container too:

- Developing inside a Container: https://code.visualstudio.com/docs/remote/containers


You can run code-server to run VS Code inside the docker container where your files will be. This is the Dockerfile I use, which I got from someone else's link that was posted on HN:

# the base miniconda3 image

FROM continuumio/miniconda3:latest

# load in the environment.yml file - this file controls what Python packages we install

ADD environment.yml /

# install the Python packages we specified into the base environment

RUN conda update -n base conda -y && conda env update && conda install -y -q moto && conda install -y -q -c conda-forge awscli httmock

# download the coder binary, untar it, and allow it to be executed

RUN wget https://github.com/cdr/code-server/releases/download/2.1698/... \ && tar -xzvf code-server2.1698-vsc1.41.1-linux-x86_64.tar.gz && chmod +x code-server2.1698-vsc1.41.1-linux-x86_64/code-server

COPY docker-entrypoint.sh /usr/local/bin/

ADD ./code /code

ENTRYPOINT ["docker-entrypoint.sh"]

Building that and running it with: docker run -d -p 127.0.0.1:8443:8080 -p 127.0.0.1:8888:8888 -v $(pwd)/data:/data -v $(pwd)/code:/code --rm -it <image>

from the directory where your code is will put those files into the container, and start a VS Code and a Jupyter Notebook server on your localhost. The password for Jypter is the default "local-development" and the password for the VS Code instance is in the Docker logs. You can set these via the Dockerfile but I just keep the defaults.

I vastly prefer this to anything else because it means I can install any packages I want without worrying about messing up my environment. You can use virtual envs to make this even better, but I am typically too dumb and lazy for that. Better part still is that my development is the same on my Mac, on my Linux machine, and on my Windows machine. Same VS Code version, same packages, etc.

Biggest issue here is with certain VS Code plugins. Some, like the vim plugin, can be finicky and depend heavily on the version of code server that you use. Some plugins break completely. However, I mainly hate plugins so this doesn't present much of an issue for me personally. I have the vim plugin, the python plugin, and a terraform plugin installed. Once they are installed, they work perfectly for me.

The way my set up works is I have a repo with that Dockerfile in it as well as the accompanying files such as environment.yml and docker-entrypoint.sh:

#!/bin/bash set -e

if [ $# -eq 0 ] then jupyter lab --ip=0.0.0.0 --NotebookApp.token='local-development' --allow-root --no-browser &> /dev/null & code-server2.1698-vsc1.41.1-linux-x86_64/code-server --allow-http --no-auth --data-dir /data /code else exec "$@" fi

and a .gitignore file with this in it:

code/*

data/*

Oh also I found the repo where I took these things from: https://github.com/caesarnine/data-science-docker-vscode-tem...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: