From 10f93ea9e1f0dc2580513150a78c48c4a73d5859 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Thu, 30 Nov 2023 13:50:51 -0500 Subject: [PATCH] feat: adds custom dev container configuration (#84) Note that this does not having podman installed and does not support working on or running the end to end tests. Signed-off-by: Jennifer Power --- .devcontainer/Dockerfile | 30 ++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..8688509d --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,30 @@ +FROM quay.io/fedora/fedora:37 + +ARG POETRY_VERSION=1.5.1 + +RUN dnf -y update && \ + yum -y reinstall shadow-utils && \ + yum install -y git \ + python3 \ + python3-pip \ + python3-devel \ + gcc-c++ && \ + rm -rf /var/cache /var/log/dnf* /var/log/yum.* + +RUN useradd -u 1000 trestlebot + +ENV HOME=/home/trestlebot +ENV PYSETUP_PATH="$HOME/trestle-bot" \ + VENV_PATH="$HOME/trestle-bot/.venv" + +RUN mkdir -p "$PYSETUP_PATH" + +# Installing poetry and pipx. +RUN python3 -m pip install --no-cache-dir --upgrade pip \ + && python3 -m pip install --no-cache-dir pipx \ + && python3 -m pipx install poetry==$POETRY_VERSION + +# set permissions +RUN chown trestlebot:trestlebot -R /home/trestlebot + +USER trestlebot \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..a140768f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +{ + "name": "TrestleBot Dev Environment ", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "customizations": { + "vscode": { + "settings": { + "python.linting.enabled": true, + "python.defaultInterpreterPath": "/home/trestlebot/trestle-bot/.venv/bin/python3" + }, + "extensions": [ + "ms-python.python", + "ms-python.mypy-type-checker", + "ms-python.flake8", + "ms-python.isort", + "ms-azuretools.vscode-docker" + ] + } + }, + "updateRemoteUserUID": true, + "containerUser": "trestlebot", + "containerEnv": { + "HOME": "/home/trestlebot", + "PIP_NO_CACHE_DIR": "off", + "PIP_DISABLE_PIP_VERSION_CHECK": "on", + "PIP_DEFAULT_TIMEOUT": "100", + "POETRY_VIRTUALENVS_IN_PROJECT": "true" + }, + "updateContentCommand": "python3 -m venv $VENV_PATH && source $VENV_PATH/bin/activate && poetry install --no-root --no-interaction", + "postCreateCommand": "echo \"source $VENV_PATH/bin/activate\" >> $HOME/.bashrc", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", + "workspaceFolder": "/workspace" +} \ No newline at end of file