add VSCode devcontainer setup

pull/16/head
scito 2 years ago
parent 4027677b38
commit fb4cee14da

@ -0,0 +1,37 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.134.0/containers/python-3/.devcontainer/base.Dockerfile
# [Choice] Python version: 3, 3.10, ...
ARG VARIANT=3
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
&& apt-get purge -y imagemagick imagemagick-6-common \
# Install common packages, non-root user
# && /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
# Clean up
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# [Option] Install Node.js
# ARG INSTALL_NODE="false"
# ARG NODE_VERSION="lts/*"
# RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# [Optional] Allow the vscode user to pip install globally w/o sudo
# ENV PIP_TARGET=/usr/local/pip-global
# ENV PYTHONPATH=${PIP_TARGET}:${PYTHONPATH}
# ENV PATH=${PIP_TARGET}/bin:${PATH}
# RUN mkdir -p ${PIP_TARGET} \
# && chown vscode:root ${PIP_TARGET} \
# && echo "if [ \"\$(stat -c '%U' ${PIP_TARGET})\" != \"vscode\" ]; then chown -R vscode:root ${PIP_TARGET}; fi" \
# | tee -a /root/.bashrc /home/vscode/.bashrc /root/.zshrc >> /home/vscode/.zshrc
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update \
# && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

@ -0,0 +1,22 @@
// Docu: https://containers.dev/implementors/json_reference/
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
//Update 'VARIANT' to pick a Python version: 3, 3.10, ...
"args": {
"VARIANT": "3.10"
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python"
],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand":
"python -m pip install --upgrade pip; pip install -r requirements-dev.txt; pip install -r requirements.txt",
"postStartCommand": "echo 'Happy coding'"
// Comment out to connect as root instead.
// "remoteUser": "vscode"
}

9
.gitignore vendored

@ -1,12 +1,15 @@
generated_python/__pycache__/
__pycache__/
qr/
venv/
*.csv
*.json
/*.csv
/*.json
!devbox.json
!example_output.json
!example_output.csv
!.github/
!.flake8
.vscode
!.vscode/settings.json
!.devcontainer/
!.devcontainer/*.json

@ -64,13 +64,26 @@ pipenv shell
python extract_otp_secret_keys.py example_export.txt
```
### Visual Studio Code Remote - Containers / VSCode devcontainer
You can you use [VSCode devcontainer](https://code.visualstudio.com/docs/remote/containers-tutorial) for running extract_otp_secret_keys.
Requirement: Docker
1. Start VSCode
2. Open extract_otp_secret_keys.code-workspace
3. Open VSCode command palette (Ctrl-Shift-P)
4. Type command "Remote-Containers: Reopen in Container"
5. Open integrated bash terminal in VSCode
6. Execute: python extract_otp_secret_keys.py example_export.txt
### venv
Alternatively, you can use a python virtual env for the dependencies:
python -m venv venv
. venv/bin/activate
pip install -r requirements-buildenv.txt
pip install -r requirements-dev.txt
pip install -r requirements.txt
The requirements\*.txt files contain all the dependencies (also the optional ones).

@ -0,0 +1,7 @@
{
"folders": [
{
"path": "."
}
]
}

@ -0,0 +1,4 @@
wheel
pytest
flake8
pylint
Loading…
Cancel
Save